Android NDK build vsomeip3
Build Boost for Android
https://github.com/moritz-wundke/Boost-for-Android
set the NDK_ROOT environment
export NDK_ROOT=~/Android/Sdk/ndk/23.1.7779620
if you have downloaded the boost_1_74_0.tar.bz2 already, then you have no need to download it again,
just comment the download_file
part in the build-android.sh
449 # Downalod and unzip boost in a temporal folder and
450 if [ ! -f $BOOST_TAR ]
451 then
452 echo "Downloading boost ${BOOST_VER1}.${BOOST_VER2}.${BOOST_VER3} please wait..."
453 prepare_download
454 download_file $BOOST_DOWNLOAD_LINK $PROGDIR/$BOOST_TAR
455 fi
the download_file function is implemented in the build-common.sh.
25 # Add common build methods
26 . "$SCRIPTDIR"/build-common.sh
please refer to build-common.sh to see the implementation of download_file ()
292 # Download a file with either 'curl', 'wget' or 'scp'
293 #
294 # $1: source URL (e.g. http://foo.com, ssh://blah, /some/path)
295 # $2: target file
296 download_file ()
297 {
298 # Is this HTTP, HTTPS or FTP ?
299 if pattern_match "^(http|https|ftp):.*" "$1"; then
300 if [ -n "$CMD_WGET" ] ; then
301 run $CMD_WGET -O $2 $1
302 elif [ -n "$CMD_CURL" ] ; then
303 run $CMD_CURL -L -o $2 $1
304 else
305 echo "Please install wget or curl on this machine"
306 exit 1
307 fi
308 return
309 fi
310
311 # Is this SSH ?
312 # Accept both ssh://<path> or <machine>:<path>
313 #
314 if pattern_match "^(ssh|[^:]+):.*" "$1"; then
315 if [ -n "$CMD_SCP" ] ; then
316 scp_src=`echo $1 | sed -e s%ssh://%%g`
317 run $CMD_SCP $scp_src $2
318 else
319 echo "Please install scp on this machine"
320 exit 1
321 fi
322 return
323 fi
324
325 # Is this a file copy ?
326 # Accept both file://<path> or /<path>
327 #
328 if pattern_match "^(file://|/).*" "$1"; then
329 cp_src=`echo $1 | sed -e s%^file://%%g`
330 run cp -f $cp_src $2
331 return
332 fi
333 }
run the build-android.sh, choose 1.74.0 or 1.76.0
./build-android.sh $(NDK_ROOT) --boost=1.76.0
the generated libraries:
~/build-android-space/Boost-for-Android-master/build/out/arm64-v8a
Build vsomeip
https://github.com/COVESA/vsomeip
set the CMAKEPATH environment
export CMAKEPATH=~/Android/Sdk/cmake/3.18.1/bin
set the ANDROID_NDK environment
export ANDROID_NDK=~/Android/Sdk/ndk/23.1.7779620
rename these libraries in the ~/build-android-space/Boost-for-Android-master/build/out/arm64-v8a/lib
mv libboost_filesystem-clang-mt-a64-1_76.a libboost_filesystem.a
mv libboost_system-clang-mt-a64-1_76.a libboost_system.a
mv libboost_thread-clang-mt-a64-1_76.a libboost_thread.a
use cmake
mkdir build && cd build
choose -DANDROID_STL=c++_shared or -DANDROID_STL=c++_static
$CMAKEPATH/cmake .. -DBoost_INCLUDE_DIR=~/build-android-space/Boost-for-Android-master/build/out/arm64-v8a/include/boost-1_76 \
-DBoost_LIBRARY_DIR=~/build-android-space/Boost-for-Android-master/build/out/arm64-v8a/lib \
-DCMAKE_SYSTEM_NAME=Android \
-DNDKPATH=~/Android/Sdk/ndk/23.1.7779620 \
-DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK/build/cmake/android.toolchain.cmake \
-DANDROID_ABI="arm64-v8a" \
-DANDROID_NDK=$ANDROID_NDK \
-DANDROID_NATIVE_API_LEVEL=30 \
-DANDROID_PLATFORM=android-30 \
-DANDROID_STL=c++_shared \
-DCMAKE_BUILD_TYPE=${BUILDTYPE} \
-DANDROID_TOOLCHAIN=clang \
-DBOOST_ROOT=~/build-android-space/Boost-for-Android-master/build/out/arm64-v8a
After the cmake success, run make.
make
Check the Errors.
build-android-space/vsomeip-master/build$ make
Scanning dependencies of target vsomeip3
[ 1%] Building CXX object CMakeFiles/vsomeip3.dir/implementation/endpoints/src/client_endpoint_impl.cpp.o
[ 2%] Building CXX object CMakeFiles/vsomeip3.dir/implementation/endpoints/src/credentials.cpp.o
[ 3%] Building CXX object CMakeFiles/vsomeip3.dir/implementation/endpoints/src/endpoint_definition.cpp.o
[ 4%] Building CXX object CMakeFiles/vsomeip3.dir/implementation/endpoints/src/endpoint_impl.cpp.o
In file included from /home/linxu/Workspace/build-android-space/vsomeip-master/implementation/endpoints/src/endpoint_impl.cpp:8:
In file included from /home/linxu/Workspace/build-android-space/vsomeip-master/implementation/helper/1.76/boost/asio/ip/udp_ext.hpp:20:
In file included from /home/linxu/Workspace/build-android-space/vsomeip-master/implementation/helper/1.76/boost/asio/basic_datagram_socket_ext.hpp:21:
In file included from /home/linxu/Workspace/build-android-space/vsomeip-master/implementation/helper/1.76/boost/asio/basic_socket_ext.hpp:37:
In file included from /home/linxu/Workspace/build-android-space/vsomeip-master/implementation/helper/1.76/boost/asio/detail/reactive_socket_service_ext.hpp:35:
In file included from /home/linxu/Workspace/build-android-space/vsomeip-master/implementation/helper/1.76/boost/asio/detail/reactive_socket_service_base_ext.hpp:32:
/home/linxu/Workspace/build-android-space/vsomeip-master/implementation/helper/1.76/boost/asio/detail/reactive_socket_recvmsg_op_ext.hpp:44:7: error: no matching constructor for initialization of 'boost::asio::detail::reactor_op_ext'
: reactor_op_ext(&reactive_socket_recvmsg_op_base_ext::do_perform, complete_func),
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/linxu/Workspace/build-android-space/vsomeip-master/implementation/helper/1.76/boost/asio/detail/reactor_op_ext.hpp:25:7: note: candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 2 were provided
class reactor_op_ext
^
/home/linxu/Workspace/build-android-space/vsomeip-master/implementation/helper/1.76/boost/asio/detail/reactor_op_ext.hpp:25:7: note: candidate constructor (the implicit move constructor) not viable: requires 1 argument, but 2 were provided
/home/linxu/Workspace/build-android-space/vsomeip-master/implementation/helper/1.76/boost/asio/detail/reactor_op_ext.hpp:32:5: note: candidate constructor not viable: requires 3 arguments, but 2 were provided
reactor_op_ext(const boost::system::error_code& success_ec,
^
In file included from /home/linxu/Workspace/build-android-space/vsomeip-master/implementation/endpoints/src/endpoint_impl.cpp:10:
In file included from /home/linxu/Workspace/build-android-space/vsomeip-master/implementation/helper/1.76/boost/asio/local/stream_protocol_ext.hpp:24:
In file included from /home/linxu/Workspace/build-android-space/vsomeip-master/implementation/helper/1.76/boost/asio/basic_socket_acceptor_ext.hpp:20:
In file included from /home/linxu/Workspace/build-android-space/vsomeip-master/implementation/helper/1.76/boost/asio/basic_socket_ext_local.hpp:37:
In file included from /home/linxu/Workspace/build-android-space/vsomeip-master/implementation/helper/1.76/boost/asio/detail/reactive_socket_service_ext_local.hpp:33:
/home/linxu/Workspace/build-android-space/vsomeip-master/implementation/helper/1.76/boost/asio/detail/reactive_socket_recvfrom_op_ext_local.hpp:40:7: error: no matching constructor for initialization of 'boost::asio::detail::reactor_op_ext_local'
: reactor_op_ext_local(&reactive_socket_recvfrom_op_base_ext_local::do_perform, complete_func),
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/linxu/Workspace/build-android-space/vsomeip-master/implementation/helper/1.76/boost/asio/detail/reactor_op_ext_local.hpp:25:7: note: candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 2 were provided
class reactor_op_ext_local
^
/home/linxu/Workspace/build-android-space/vsomeip-master/implementation/helper/1.76/boost/asio/detail/reactor_op_ext_local.hpp:25:7: note: candidate constructor (the implicit move constructor) not viable: requires 1 argument, but 2 were provided
/home/linxu/Workspace/build-android-space/vsomeip-master/implementation/helper/1.76/boost/asio/detail/reactor_op_ext_local.hpp:33:5: note: candidate constructor not viable: requires 3 arguments, but 2 were provided
reactor_op_ext_local(const boost::system::error_code& success_ec,
^
2 errors generated.
make[2]: *** [CMakeFiles/vsomeip3.dir/build.make:121: CMakeFiles/vsomeip3.dir/implementation/endpoints/src/endpoint_impl.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:210: CMakeFiles/vsomeip3.dir/all] Error 2
make: *** [Makefile:149: all] Error 2
modify the code in order to fix the errors.
vsomeip-master/implementation/helper/1.76/boost/asio/detail/reactive_socket_recvmsg_op_ext.hpp:44:7: error: no matching constructor for initialization of 'boost::asio::detail::reactor_op_ext'
: reactor_op_ext(&reactive_socket_recvmsg_op_base_ext::do_perform, complete_func)
check the code implementation of the reactor_op_ext, then we can see the reactor_op_ext needs three parameters, but there are only two parameters provided, therefore correct it this way:
: reactor_op_ext(success_ec, &reactive_socket_recvmsg_op_base_ext::do_perform, complete_func),
and fix the error in vsomeip-master/implementation/helper/1.76/boost/asio/detail/reactive_socket_recvfrom_op_ext_local.hpp:40:7
vsomeip-master/implementation/helper/1.76/boost/asio/detail/reactive_socket_recvfrom_op_ext_local.hpp:40:7: error: no matching constructor for initialization of 'boost::asio::detail::reactor_op_ext_local'
: reactor_op_ext_local(&reactive_socket_recvfrom_op_base_ext_local::do_perform, complete_func)
then make again.
Scanning dependencies of target vsomeip3-sd
[ 62%] Building CXX object CMakeFiles/vsomeip3-sd.dir/implementation/service_discovery/src/configuration_option_impl.cpp.o
[ 63%] Building CXX object CMakeFiles/vsomeip3-sd.dir/implementation/service_discovery/src/deserializer.cpp.o
[ 64%] Building CXX object CMakeFiles/vsomeip3-sd.dir/implementation/service_discovery/src/entry_impl.cpp.o
[ 65%] Building CXX object CMakeFiles/vsomeip3-sd.dir/implementation/service_discovery/src/eventgroupentry_impl.cpp.o
[ 66%] Building CXX object CMakeFiles/vsomeip3-sd.dir/implementation/service_discovery/src/ip_option_impl.cpp.o
[ 67%] Building CXX object CMakeFiles/vsomeip3-sd.dir/implementation/service_discovery/src/ipv4_option_impl.cpp.o
[ 68%] Building CXX object CMakeFiles/vsomeip3-sd.dir/implementation/service_discovery/src/ipv6_option_impl.cpp.o
[ 70%] Building CXX object CMakeFiles/vsomeip3-sd.dir/implementation/service_discovery/src/load_balancing_option_impl.cpp.o
[ 71%] Building CXX object CMakeFiles/vsomeip3-sd.dir/implementation/service_discovery/src/message_element_impl.cpp.o
[ 72%] Building CXX object CMakeFiles/vsomeip3-sd.dir/implementation/service_discovery/src/message_impl.cpp.o
[ 73%] Building CXX object CMakeFiles/vsomeip3-sd.dir/implementation/service_discovery/src/option_impl.cpp.o
[ 74%] Building CXX object CMakeFiles/vsomeip3-sd.dir/implementation/service_discovery/src/protection_option_impl.cpp.o
[ 75%] Building CXX object CMakeFiles/vsomeip3-sd.dir/implementation/service_discovery/src/remote_subscription_ack.cpp.o
[ 77%] Building CXX object CMakeFiles/vsomeip3-sd.dir/implementation/service_discovery/src/request.cpp.o
[ 78%] Building CXX object CMakeFiles/vsomeip3-sd.dir/implementation/service_discovery/src/runtime_impl.cpp.o
[ 79%] Building CXX object CMakeFiles/vsomeip3-sd.dir/implementation/service_discovery/src/selective_option_impl.cpp.o
[ 80%] Building CXX object CMakeFiles/vsomeip3-sd.dir/implementation/service_discovery/src/service_discovery_impl.cpp.o
[ 81%] Building CXX object CMakeFiles/vsomeip3-sd.dir/implementation/service_discovery/src/serviceentry_impl.cpp.o
[ 82%] Building CXX object CMakeFiles/vsomeip3-sd.dir/implementation/service_discovery/src/subscription.cpp.o
[ 83%] Linking CXX shared library libvsomeip3-sd.so
[ 83%] Built target vsomeip3-sd
Scanning dependencies of target vsomeip3-e2e
[ 85%] Building CXX object CMakeFiles/vsomeip3-e2e.dir/implementation/e2e_protection/src/buffer/buffer.cpp.o
[ 86%] Building CXX object CMakeFiles/vsomeip3-e2e.dir/implementation/e2e_protection/src/crc/crc.cpp.o
[ 87%] Building CXX object CMakeFiles/vsomeip3-e2e.dir/implementation/e2e_protection/src/e2e/profile/e2e_provider_impl.cpp.o
[ 88%] Building CXX object CMakeFiles/vsomeip3-e2e.dir/implementation/e2e_protection/src/e2e/profile/profile01/checker.cpp.o
[ 89%] Building CXX object CMakeFiles/vsomeip3-e2e.dir/implementation/e2e_protection/src/e2e/profile/profile01/profile_01.cpp.o
[ 90%] Building CXX object CMakeFiles/vsomeip3-e2e.dir/implementation/e2e_protection/src/e2e/profile/profile01/protector.cpp.o
[ 91%] Building CXX object CMakeFiles/vsomeip3-e2e.dir/implementation/e2e_protection/src/e2e/profile/profile04/checker.cpp.o
[ 93%] Building CXX object CMakeFiles/vsomeip3-e2e.dir/implementation/e2e_protection/src/e2e/profile/profile04/profile_04.cpp.o
[ 94%] Building CXX object CMakeFiles/vsomeip3-e2e.dir/implementation/e2e_protection/src/e2e/profile/profile04/protector.cpp.o
[ 95%] Building CXX object CMakeFiles/vsomeip3-e2e.dir/implementation/e2e_protection/src/e2e/profile/profile_custom/checker.cpp.o
[ 96%] Building CXX object CMakeFiles/vsomeip3-e2e.dir/implementation/e2e_protection/src/e2e/profile/profile_custom/profile_custom.cpp.o
[ 97%] Building CXX object CMakeFiles/vsomeip3-e2e.dir/implementation/e2e_protection/src/e2e/profile/profile_custom/protector.cpp.o
[ 98%] Building CXX object CMakeFiles/vsomeip3-e2e.dir/implementation/e2e_protection/src/e2exf/config.cpp.o
[100%] Linking CXX shared library libvsomeip3-e2e.so
[100%] Built target vsomeip3-e2e
the generated shared libraries:
file *.so
libvsomeip3-cfg.so: ELF 64-bit LSB shared object, ARM aarch64, version 1 (SYSV), dynamically linked, BuildID[sha1]=7a14aa107a2f62e8db6608123edd0421989217d2, with debug_info, not stripped
libvsomeip3-e2e.so: ELF 64-bit LSB shared object, ARM aarch64, version 1 (SYSV), dynamically linked, BuildID[sha1]=2b678294813895ba281f4193a68eefbfc73f1bbc, with debug_info, not stripped
libvsomeip3-sd.so: ELF 64-bit LSB shared object, ARM aarch64, version 1 (SYSV), dynamically linked, BuildID[sha1]=876ba6d75447c1d2fff5ee397c378e716b6479d1, with debug_info, not stripped
libvsomeip3.so: ELF 64-bit LSB shared object, ARM aarch64, version 1 (SYSV), dynamically linked, BuildID[sha1]=4f780a50da6f90d07681d9e8b8193a1a632a63fe, with debug_info, not stripped
Extra
the libvsomeip3.so needs libc++_shared.so
readelf -d libvsomeip3.so |grep NEED
0x0000000000000001 (NEEDED) Shared library: [liblog.so]
0x0000000000000001 (NEEDED) Shared library: [libm.so]
0x0000000000000001 (NEEDED) Shared library: [libc++_shared.so]
0x0000000000000001 (NEEDED) Shared library: [libdl.so]
0x0000000000000001 (NEEDED) Shared library: [libc.so]
0x000000006ffffffe (VERNEED) 0x1c810
if you buid with -DANDROID_STL=c++_static
readelf -d libvsomeip3.so |grep NEED
0x0000000000000001 (NEEDED) Shared library: [liblog.so]
0x0000000000000001 (NEEDED) Shared library: [libm.so]
0x0000000000000001 (NEEDED) Shared library: [libdl.so]
0x0000000000000001 (NEEDED) Shared library: [libc.so]
0x000000006ffffffe (VERNEED) 0x286b0
0x000000006fffffff (VERNEEDNUM) 2
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 按钮权限的设计及实现
· 25岁的心里话