Android NDK r10c compilation boost 1.55 (using Cygwin)

Source: Internet
Author: User

Project used to boost::asio,boost::serialization, Android packaging environment configuration ... Make a record, next time don't fall into this hole to waste time

1. Install Cygwin:

Download Cygwin (http://www.cygwin.com/)

At the time of installation, the default setting is to select only Devel, change the following default to install, and then wait.

After installation, enter Cygwin terminal, respectively Gcc-v and make-v view version

Configure environment variables, open VI ~/.bash_profile, ADD environment variables export NDK=/CYGDRIVE/D/ANDROID/ANDROID-NDK-R10C

Enter $NDK to see if it takes effect

2. NDK compile boost generates a static library:

Enter Cygwin terminal, unzip boost_1_55_0.tar.bz2 to android-ndk-r10c/sources folder

# tar -jxvf boost_1_55_0. tar. bz2

Enter boost_1_55_0/directory to run bootstrap.sh build B2

 

Go to Boost_1_55_0/tools/build/v2/user-config.jam and add at the back:

import OS; if[Os.name] = CYGWIN | | [Os.name] =NT {androidplatform= windows-x86_64; }  Else if[Os.name] =LINUX {androidplatform= linux-x86_64; }  Else if[Os.name] =MacOSX {androidplatform= darwin-x86; } modules.poke:NO_BZIP2:1 ; #ANDROID_NDK= .. /.. ; ANDROID_NDK= d:/android/android-ndk-r10c; UsingGCC: Android4.8: $ (ANDROID_NDK)/toolchains/arm-linux-androideabi-4.8/prebuilt/$ (Androidplatform)/bin/arm-linux-androideabi-g++ :  <archiver>$ (ANDROID_NDK)/toolchains/arm-linux-androideabi-4.8/prebuilt/$ (Androidplatform)/bin/arm-linux-androideabi-ar<ranlib>$ (ANDROID_NDK)/toolchains/arm-linux-androideabi-4.8/prebuilt/$ (Androidplatform)/bin/arm-linux-androideabi-Ranlib<compileflags>--sysroot=$ (ANDROID_NDK)/platforms/android-9/arch-Arm<compileflags>-i$ (ANDROID_NDK)/sources/cxx-stl/gnu-libstdc++/4.8/include<compileflags>-i$ (ANDROID_NDK)/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi/include #<compileflags>-dboost_no_std_wstring<compileflags>-Dndebug<compileflags>-d__glibc__<compileflags>-dboost_filesystem_version=3<compileflags>-lstdc++ <compileflags>-lgnustl_shared<compileflags>-Mthumb<compileflags>-fno-strict-aliasing<compileflags>-std=gnu++ One<compileflags>-O2; 

Note Adjust the path of the ANDROID_NDK.

compile boost::asio,boost::serialization, generate astatic library under boost_1_55_0/Android/lib

#./B2--with-system--with-serialization toolset=gcc-android4. 8 link=static runtime-link=static target-os=linux--stagedir=android

Create a new android.mk write under the Boost_1_55_0 folder

Local_path:= $ (Call my-dir) #LOCAL_CPPFLAGS+=–fexceptionsinclude $ (clear_vars) Local_module:=Boost_system local_src_files:= android/lib/LIBBOOST_SYSTEM.A local_export_c_includes:=$ (Local_path) include $ (prebuilt_static_library) include $ (clear_vars) Local_module:=Boost_serializationlocal_src_files:= android/lib/libboost_serialization.a local_export_c_includes:=$ (Local_path) include $ (prebuilt_static_library) include $ (clear_vars) Local_module:=Boost_wserializationlocal_src_files:= android/lib/libboost_wserialization.a local_export_c_includes:=$ (Local_path) include $ (prebuilt_static_library)

3. Project Packaging

Open jni/android.mk Add

Local_whole_static_libraries + = Boost_system
Local_whole_static_libraries + = Boost_serialization

$ (call Import-module, boost_1_55_0)

Compile error:

You want to add it to the Jni/application.mk file,

App_cppflags + =-fexceptions (add exception support Local_cppflags +=–fexceptions)

Compile to boost::serialization error,

Reference http://stackoverflow.com/questions/15479136/how-to-implement-mbtowc-for-android-or-ideally-how-not-to

This type of undefined function is the C library, the NDK does not implement the class functions ... Boost Library website said believe that you can achieve, good AH ~

Add code to the CPP file instead of the undefined function

#ifdef ANDROID int wctomb (charreturn  Wcrtomb (s,wc,null);} int Const Char return MBRTOWC (PwC, S, N, NULL);} #endif

All right, so that's the app pack.

The final jni/android.mk file content is (red is the added part)

Local_path: = $ (Call my-dir) include $ (clear_vars) Local_module:=Cocos2dcpp_sharedlocal_module_filename:=Libcocos2dcpplocal_src_files:= Hellocpp/main.CPP                    ../.. /classes/appdelegate.CPP                    ../.. /classes/helloworldscene.CPPLocal_c_includes:= $ (local_path)/... /.. /classeslocal_whole_static_libraries:=cocos2dx_staticlocal_whole_static_libraries+=cocosdenshion_staticlocal_whole_static_libraries + = boost_systemlocal_whole_static_libraries + = boost_serialization#local_whole_static_libraries + = boost_wserialization# local_whole_static_libraries+=box2d_static# local_whole_static_libraries+=cocosbuilder_static# local_whole_static_libraries+=spine_static# local_whole_static_libraries+=cocostudio_static# local_whole_static_libraries+=cocos_network_static# local_whole_static_libraries+=Cocos_extension_staticinclude $ (build_shared_library) $ (Call import-module,.) $ (Call import-module,audio/Android) $ (Call import - module, BOOST_1_55_0)# $ (Call import-module,box2d) # $ (Call import-module,editor-support/cocosbuilder) # $ (Call import-module,editor-support/Spine) # $ (Call import-module,editor-support/Cocostudio) # $ (Call import-module,network) # $ (Call import-module,extensions)

The final jni/application.mk file content is (red is the added part)

App_stl: = gnustl_staticapp_cppflags:=-frtti-dcc_enable_chipmunk_integration=1 -dcocos2d_debug= 1 -std=c++ -fsigned-charapp_cppflags + =-fexceptions

Reference:
http://blog.csdn.net/ly131420/article/details/41390379http://stackoverflow.com/ Questions/15479136/how-to-implement-mbtowc-for-android-or-ideally-how-not-tohttp://  blog.csdn.net/hcj116/article/details/19752307http://stackoverflow.com/questions/17667978/ Using-boost-in-android-ndk-with-windowshttp://www.codexperiments.com/android/2011/05/ tips-tricks-building-boost-with-ndk-r5/http://blog.csdn.net/andyhuabing/article/details/ 8594679

Android NDK r10c compilation boost 1.55 (using Cygwin)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.