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

Android NDK build vsomeip3的更多相关文章

  1. 〖Linux〗Clang/Clang++ for Android Binary/NDK build(二进制可执行文件/NDK编译)

    #1. 下载并安装NDK(解压即可,目前最新版是r9c) http://developer.android.com/tools/sdk/ndk/index.html #2. 安装NDK独立编译工具 c ...

  2. Android NDK debug 方法

    最近又频繁遇到 NDK 的错误,记录一下debug调试的一些经验,以备后续查看 一般来说,在Android Studio中的Monitor中将过滤器的 LOG TAG 设置为 "DEBUG& ...

  3. 初识Android NDK

    本文介绍Windows环境下搭建Android NDK开发环境,并创建一个简单的使用Native代码的Android Application. 一.环境搭建 二.JNI函数绑定 三.例子 一.环境搭建 ...

  4. Android NDK之JNI陷阱

    背景: 最近一个月一直在做移植库的工作,将c代码到share library移植到Android平台.这就涉及到Android NDK(native develop kit)内容.这里只想记录下JNI ...

  5. Android NDK开发

    Android NDK 开发教程(极客学院) 一.Android NDK环境搭建 使用最新ndk,直接抛弃cygwin,以前做Android的项目要用到NDK就必须要下载NDK,下载安装Cygwin( ...

  6. Eclipse+CDT+GDB调试android NDK程序(转)

    Eclipse+CDT+gdb调试android ndk程序 先介绍一下开发环境,在这个环境下,up主保证是没有问题的. ubuntu 11.10 eclipse 3.7(indego) for ja ...

  7. android NDK入门 windows下安装cygwin

    一.Android NDK环境简介 Android NDK 是运行于Android 平台上的Native Development Kit 的缩写. Android 应用开发者可以通过NDK 调用C 或 ...

  8. windows系统上安装与使用Android NDK r5 (转)

    windows系统上安装与使用Android NDK r5  很早就听说了android的NDK应用,只是一直没有时间去研究,今天花了点时间在windows平台搭建了NDK环境,并成功运行了第一个简单 ...

  9. Android NDK开发入门实例

    AndroidNDK是能使Android应用开发者把从c/c++编译而来的本地代码嵌入到应用包中的一系列工具的组合. 注意: AndroidNDK只能用于Android1.5及以上版本中. I. An ...

  10. [原]如何用Android NDK编译FFmpeg

    我们知道在Ubuntu下直接编译FFmpeg是很简单的,主要是先执行./configure,接着执行make命令来编译,完了紧接着执行make install执行安装.那么如何使用Android的ND ...

随机推荐

  1. c#反射优化

    https://www.cnblogs.com/xinaixia/p/5777886.html https://www.cnblogs.com/xinaixia/p/5777961.html

  2. js获取input处理

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  3. js-解决安卓手机软键盘弹出后,固定定位布局被顶上移问题

    分析:软键盘弹出后,导致页面高度变化 解决方案:软键盘弹出后,修复页面高度 // 监听窗口变化 resizeScreen(){ if (!this.state.isIOS && thi ...

  4. vue项目中禁用浏览器缓存配置案例

    项目发布新版本,部署线上后用户浏览器需要清理缓存 1.public文件夹中修改 index.html文件meta配置 <meta http-equiv="Cache-Control&q ...

  5. VIT论文笔记

    VIT An image is worth 16x16 words: transformers for image recognition at scale 将transformer首次应用在视觉任务 ...

  6. 【面试题】XSS攻击是什么?

    XSS攻击是什么? 要点: XSS是跨站脚本攻击.向目标网站插入恶意代码.大量用户访问网站时运行恶意脚本获取信息 答: XSS是跨站脚本攻击(Cross Site Scripting),不写为CSS是 ...

  7. sql server某列根据逗号转多行,其它字段不变

    效果: 语句代码: declare @moulds varchar(4000); set @moulds='55-480730-03,55-487780-01,,55-487780-02 '; dec ...

  8. git基础代码获取

    1.新建文件夹 2.使用命令git init 初始化 3.见你与远程厂库的连接,git remote add origin 远程仓库地址 4.将远程仓库代码拉去到本地,git fetch origin ...

  9. Java运算符(复习)

    运算符 运算符:对字面量或者变量进行操作的符号 表达式:用运算符把字面量或者变量连接起来,符合Java语法的式子就可以称为表达式. 算数运算符 符号 作用 + 加法作用 - 减法作用 * 乘法作用 / ...

  10. 常用ansible命令梳理

    命令的具体格式 : ansible <host-pattern> [-f forks] [-m module_name] [-a args] 场景 命令 查询线上所有机器某个文件的含有某个 ...