如何使用静态Boost库为Android链接? [英] How link with static boost libraries for android?
本文介绍了如何使用静态Boost库为Android链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有问题,移植和链接Boost库使用Android的NDK-R5B到Android。 我先建Boost库(无MPI,蟒蛇)使用以下步骤:
1.commented在boost_1_46_0线53 \库\螺纹\编译:
#如果[os.name] =NT{API = Win32的; }
2。创建该文件的用户config.jam中的升压根目录
androidNDKRoot = ../android-ndk-r5b; 使用gcc:android4.4.3: $(androidNDKRoot)/toolchains/arm-linux-androideabi-4.4.3/$p$pbuilt/windows/bin/arm-linux-androideabi-g++.exe : --sysroot = $(androidNDKRoot)/平台/ Android的3 /弓臂 -mthumb -Os -fno严格走样 -O2 -DNDEBUG -G -fexceptions -frtti -lstdc ++ -I $(androidNDKRoot)/来源/ CXX-STL / GNU-的libstdc ++ /包括 -I $(androidNDKRoot)/来源/ CXX-STL / GNU-的libstdc ++ /库/ armeabi /包括 -D__GLIBC__ -DBOOST_NO_INTRINSIC_WCHAR_T $(androidNDKRoot)/toolchains/arm-linux-androideabi-4.4.3/$p$pbuilt/windows/bin/arm-linux-androideabi-ar.exe $(androidNDKRoot)/toolchains/arm-linux-androideabi-4.4.3/$p$pbuilt/windows/bin/arm-linux-androideabi-ranlib.exe Linux的 ;
3。打造提升
bjam.exe --user-配置=用户config.jam中--without-蟒蛇--without-MPI工具= GCC-android4.4.3链接=静态运行时链接=静态目标-OS = Linux的--stagedir =机器人> D:\ out.txt
4。 Application.mk
APP_STL:= gnustl_static APP_PLATFORM:=机器人-3 APP_CPPFLAGS + = -mthumb APP_CPPFLAGS + = -Os APP_CPPFLAGS + = -fno严格走样 APP_CPPFLAGS + = -O2 APP_CPPFLAGS + = -DNDEBUG APP_CPPFLAGS + = -g APP_CPPFLAGS + = -fexceptions APP_CPPFLAGS + = -frtti APP_CPPFLAGS + = -lstdc ++ APP_CPPFLAGS + = -D__GLIBC__ APP_CPPFLAGS + = -DBOOST_NO_INTRINSIC_WCHAR_T APP_CPPFLAGS + = -L / cygdrive /天/安卓/ boost_1_46_0 /安卓/ lib中/
5。 Android.mk
# 如何 #http://source.android.com/porting/build_cookbook.html # LOCAL_PATH:= $(叫我-DIR) #================================================= ============= #libudt #================================================= ============= 包括$(CLEAR_VARS) LOCAL_MODULE:= libudt LOCAL_C_INCLUDES + = / cygdrive /天/安卓/ boost_1_46_0 / LOCAL_SRC_FILES + = udt.cpp LOCAL_STATIC_LIBRARIES:= boost_thread-GCC-MT-S-1_46 包括$(BUILD_SHARED_LIBRARY)
6。 udt.cpp
#包括升压/ bind.hpp #包括升压/ thread.hpp 无效thread_fn(INT) { } 为externCINT FUNC1() { 提高::线程THRD(的boost ::绑定(thread_fn,1)); thrd.join(); 返回0; }
7。 $ NDK / NDK建造
++编译大拇指:UDT>>>: D:/Android/boost_1_46_0/boost/thread/detail/thread.hpp:204:未定义参考`的boost ::螺纹:: start_thread() D:/Android/boost_link/obj/local/armeabi/objs/udt/udt.o:在功能`FUNC1: D:/Android/boost_link/jni/udt.cpp:19:未定义的参考`的boost ::螺纹::连接()' D:/Android/boost_link/jni/udt.cpp:20:未定义的参考`的boost ::螺纹::〜线程() D:/Android/boost_link/jni/udt.cpp:20:未定义的参考`的boost ::螺纹::〜线程() D:/Android/boost_link/obj/local/armeabi/objs/udt/udt.o:(.data.rel.ro._ZTIN5boost6detail11thread_dataINS_3_bi6bind_tIvPFv iENS2_5list1INS2_5valueIiEEEEEEEE [所属类别升压::详细:: thread_data>>>] + 0x8中):未定义的参考`所属类别升压::详细:: thread_data_base collect2:劳工处返回1退出状态 使:*** [/cygdrive/d/Android/boost_link/obj/local/armeabi/libudt.so]错误1
解决方案
目前,我们通过简单地包括的makefile库相关提振文件使用升压的某些部分。
I have problem porting and linking the boost libraries to android using Android-ndk-r5b. I build boost libraries first (without mpi, python) using these steps:
1.commented line 53 in boost_1_46_0\libs\thread\build:
# if [ os.name ] = "NT" { api = win32 ; }
2. create the file user-config.jam in boost root directory
androidNDKRoot = ../android-ndk-r5b ; using gcc : android4.4.3 : $(androidNDKRoot)/toolchains/arm-linux-androideabi-4.4.3/prebuilt/windows/bin/arm-linux-androideabi-g++.exe : --sysroot=$(androidNDKRoot)/platforms/android-3/arch-arm -mthumb -Os -fno-strict-aliasing -O2 -DNDEBUG -g -fexceptions -frtti -lstdc++ -I$(androidNDKRoot)/sources/cxx-stl/gnu-libstdc++/include -I$(androidNDKRoot)/sources/cxx-stl/gnu-libstdc++/libs/armeabi/include -D__GLIBC__ -DBOOST_NO_INTRINSIC_WCHAR_T $(androidNDKRoot)/toolchains/arm-linux-androideabi-4.4.3/prebuilt/windows/bin/arm-linux-androideabi-ar.exe $(androidNDKRoot)/toolchains/arm-linux-androideabi-4.4.3/prebuilt/windows/bin/arm-linux-androideabi-ranlib.exe linux ;
3. build boost
bjam.exe --user-config=user-config.jam --without-python --without-mpi toolset=gcc-android4.4.3 link=static runtime-link=static target-os=linux --stagedir=android > d:\out.txt
4. Application.mk
APP_STL := gnustl_static APP_PLATFORM := android-3 APP_CPPFLAGS += -mthumb APP_CPPFLAGS += -Os APP_CPPFLAGS += -fno-strict-aliasing APP_CPPFLAGS += -O2 APP_CPPFLAGS += -DNDEBUG APP_CPPFLAGS += -g APP_CPPFLAGS += -fexceptions APP_CPPFLAGS += -frtti APP_CPPFLAGS += -lstdc++ APP_CPPFLAGS += -D__GLIBC__ APP_CPPFLAGS += -DBOOST_NO_INTRINSIC_WCHAR_T APP_CPPFLAGS += -L/cygdrive/d/Android/boost_1_46_0/android/lib/
5. Android.mk
# Howto # http://source.android.com/porting/build_cookbook.html # LOCAL_PATH:= $(call my-dir) # ============================================================== # libudt # ============================================================== include $(CLEAR_VARS) LOCAL_MODULE := libudt LOCAL_C_INCLUDES += /cygdrive/d/Android/boost_1_46_0/ LOCAL_SRC_FILES += udt.cpp LOCAL_STATIC_LIBRARIES := boost_thread-gcc-mt-s-1_46 include $(BUILD_SHARED_LIBRARY)
6. udt.cpp
#include "boost/bind.hpp" #include "boost/thread.hpp" void thread_fn (int) { } extern "C" int func1 () { boost::thread thrd (boost::bind (thread_fn, 1)); thrd.join (); return 0; }
7. $NDK/ndk-build
Compile++ thumb : udt > > >': D:/Android/boost_1_46_0/boost/thread/detail/thread.hpp:204: undefined reference to `boost::thread::start_thread()' D:/Android/boost_link/obj/local/armeabi/objs/udt/udt.o: In function `func1': D:/Android/boost_link/jni/udt.cpp:19: undefined reference to `boost::thread::join()' D:/Android/boost_link/jni/udt.cpp:20: undefined reference to `boost::thread::~thread()' D:/Android/boost_link/jni/udt.cpp:20: undefined reference to `boost::thread::~thread()' D:/Android/boost_link/obj/local/armeabi/objs/udt/udt.o:(.data.rel.ro._ZTIN5boost6detail11thread_dataINS_3_bi6bind_tIvPFv iENS2_5list1INS2_5valueIiEEEEEEEE[typeinfo for boost::detail::thread_data > > >]+0x8): undefined reference to `typeinfo for boost::detail::thread_data_base' collect2: ld returned 1 exit status make: *** [/cygdrive/d/Android/boost_link/obj/local/armeabi/libudt.so] Error 1
解决方案
We currently use some parts of boost by simply including relevant boost files in the makefile for the library.
这篇关于如何使用静态Boost库为Android链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文