转载:
就怕这种事:沙漠中的海市蜃楼。
NDK r5 中 的 C++ STL 就是。
http://www.modoohut.com/archives/%E8%AF%95%E4%BA%86%E4%B8%8Bandroid-ndk-r5.html
Android, by cola_tin.
始终觉得google在NDK上花的力气不够, NDK对c++的支持很不好, 或许g认为在NDK下应该用C++是奢侈的, 那tmd上层还java虚拟机呢. NDK r4虽然支持c++, 但是没有stl支持(没有stl的c++还算c++吗), 幸好有个crystax的版本, 对stl支持很好.
NKD r5出来有段时间了, 今天看了一下, 对c++的支持大有改进, 加入两种stl的实现, 一个默认的和一个gnu的. 于是把r4 crystax换成r5试了下, 默认的那个stl链接时老是报~exception multiple definition, 换gnu版本就ok了. 在2.2的虚拟机下跑了下, 正常, 换到2.1就出问题了, 2.1还没法用gdb调试. 用”ndk r5 2.1″狗了一下, 发现很多人有这样的问题, 找到一个解释 https://review.source.android.com//#change,21309 (没被墙, 表示惊讶). 引用如下
Due to a bug in the implementation of __cxa_finalize() that was only
fixed in Android 2.2, any code linked with gnustl_static would crash
when running on Android 2.1 or older.This adds a local patch to libsupc++ to detect the problem at runtime
and avoid the crash. Note that this results in a leak of a thread-specific
storage key on these older platforms.
也就是说ndk r5编译的c++ native无法在2.1及以下版本跑, 这不扯淡嘛, 算了, 继续用r4 crystax.
http://blog.zcube.kr/5498
2011.02.21 15:01
Android ndk에서 부터는 C++의 RTTI와 exception을 지원하게 되었다.
하지만 왠지 환경을 세팅하고 빌드를 해도 잘 동작하지 않았고..
이런 저런 뻘짓 결과 STL을 위한 libstdc++.a 라이브러리가 arm-linux-androideabi-4.4.3 기준으로만
빌드 되어 있기 때문이라는 걸로 결론을 내렸다.
아직은 r4b-crystax를 써야 할듯 하다.
---
http://blog.zcube.kr/1993
CMake로 CURL을 Android에 맞게 빌드 해 봤다
2010.03.30 22:07
set EABI_VERSION=4.2.1 set GLIBC_ADDON_OPTIONS=crtbegin_dynamic.o set GCC_ROOT_DIRECTORY=c:/Programs/android-ndk-r3/build/prebuilt/windows/arm-eabi-%EABI_VERSION% REM set path=%GCC_ROOT_DIRECTORY%/bin;%GCC_ROOT_DIRECTORY%/libexec/gcc/arm-eabi/%EABI_VERSION%;"C:/Program Files/CMake 2.8/bin";"C:/cygwin/bin" set path=%GCC_ROOT_DIRECTORY%/bin;%GCC_ROOT_DIRECTORY%/libexec/gcc/arm-eabi/%EABI_VERSION%;"C:/Program Files/CMake 2.8/bin";C:/cygwin/bin set GCC_ROOT_DIRECTORY=/cygdrive/c/Programs/android-ndk-r3/build/prebuilt/windows/arm-eabi-%EABI_VERSION% set CPLUS_INCLUDE_PATH=%GCC_ROOT_DIRECTORY%/include:%GCC_ROOT_DIRECTORY%/lib/gcc/arm-eabi/%EABI_VERSION%/include:/cygdrive/c/Programs/android-ndk-r3/build/platforms/android-5/arch-arm/usr/include:%GCC_ROOT_DIRECTORY%/lib/gcc/arm-eabi/%EABI_VERSION%/install-tools/include:%GCC_ROOT_DIRECTORY%/lib/gcc/arm-eabi/%EABI_VERSION%/install-tools set C_INCLUDE_PATH=%CPLUS_INCLUDE_PATH% set TARGET_DIRECTORY=/cygdrive/c/Programs/android-ndk-r3/build/platforms/android-5 set LD_LIBRARY_PATH=%GCC_ROOT_DIRECTORY%/lib:%GCC_ROOT_DIRECTORY%/lib/gcc/arm-eabi/%EABI_VERSION%/android:%TARGET_DIRECTORY%/arch-arm/usr/lib set LDPATH=%LD_LIBRARY_PATH% rem -DHAVE_GLIBC_STRERROR_R=1 -D__EABI__ rem -nostdlib -Wl,-rpath-link=/cygdrive/c/Programs/android-ndk-r3/build/platforms/android-5/arch-arm/usr/lib -L/cygdrive/c/Programs/android-ndk-r3/build/platforms/android-5/arch-arm/usr/lib -lc /cygdrive/c/Programs/android-ndk-r3/build/platforms/android-5/arch-arm/usr/lib/crtbegin_dynamic.o set LINK_FLAGS=-nostdlib -Wl,-rpath-link=/cygdrive/c/Programs/android-ndk-r3/build/platforms/android-5/arch-arm/usr/lib -L/cygdrive/c/Programs/android-ndk-r3/build/platforms/android-5/arch-arm/usr/lib -lc set EXE_FLAGS= /cygdrive/c/Programs/android-ndk-r3/build/platforms/android-5/arch-arm/usr/lib/crtbegin_dynamic.o set GCC_EXTRA_CONFIG=-nostdlib -Wl,-rpath-link=%TARGET_DIRECTORY%/arch-arm/usr/lib -L/cygdrive/c/Programs/android-ndk-r3/build/platforms/android-5/arch-arm/usr/lib %TARGET_DIRECTORY%/arch-arm/usr/lib/crtbegin_static.o -lc -DHAVE_GLIBC_STRERROR_R=1 -D__EABI__ set PREFIX=arm-eabi- set GXX=%PREFIXg++.exe set GCC=%PREFIXgcc.exe set ARM_BIN=C:/Programs/android-ndk-r3/build/prebuilt/windows/arm-eabi-%EABI_VERSION%/bin/ set GCC_ROOT_DIRECTORY=/cygdrive/c/Programs/android-ndk-r3/build/prebuilt/windows/arm-eabi-%EABI_VERSION% set flags=-DCMAKE_BUILD_TYPE="MinSizeRel" -G "MinGW Makefiles" -DCMAKE_CXX_COMPILER="%ARM_BIN%%PREFIX%g++.exe" -DCMAKE_C_COMPILER="%ARM_BIN%%PREFIX%gcc.exe" -DCMAKE_AR="%ARM_BIN%%PREFIX%ar.exe" -DCMAKE_LINKER="%ARM_BIN%%PREFIX%ld.exe" -DCMAKE_SYSTEM_NAME="linux" -DCMAKE_C_FLAGS="%GCC_EXTRA_CONFIG%" -DCMAKE_CXX_FLAGS="%GCC_EXTRA_CONFIG%" -DCURL_DISABLE_LDAP=TRUE -DCURL_DISABLE_LDAPS=TRUE -DBUILD_CURL_TESTS=FALSE -DCMAKE_EXE_LINKER_FLAGS="%LINK_FLAGS% %EXE_FLAGS%" -DCMAKE_MODULE_LINKER_FLAGS="%LINK_FLAGS%" -DCMAKE_SHARED_LINKER_FLAGS="%LINK_FLAGS%" mkdir cross cd cross cmake-gui %flags% ../ cd .. :BUILD pause @echo off cd cross c:/mingw/bin/mingw32-make.exe pause |
-nostdlib -Wl,-rpath-link=/cygdrive/c/Programs/android-ndk-r3/build/platforms/android-5/arch-arm/usr/lib -L/cygdrive/c/Programs/android-ndk-r3/build/platforms/android-5/arch-arm/usr/lib -lc /cygdrive/c/Programs/android-ndk-r3/build/platforms/android-5/arch-arm/usr/lib/crtbegin_dynamic.o |
#if defined(__GNUC__) && defined(__EABI__) #include #endif |
#elif defined(__GNUC__) # if defined(__i386__) || defined(__ppc__) # define CURL_SIZEOF_LONG 4 # define CURL_TYPEOF_CURL_OFF_T long long # define CURL_FORMAT_CURL_OFF_T "lld" # define CURL_FORMAT_CURL_OFF_TU "llu" # define CURL_FORMAT_OFF_T "%lld" # define CURL_SIZEOF_CURL_OFF_T 8 # define CURL_SUFFIX_CURL_OFF_T LL # define CURL_SUFFIX_CURL_OFF_TU ULL # elif defined(__x86_64__) || defined(__ppc64__) # define CURL_SIZEOF_LONG 8 # define CURL_TYPEOF_CURL_OFF_T long # define CURL_FORMAT_CURL_OFF_T "ld" # define CURL_FORMAT_CURL_OFF_TU "lu" # define CURL_FORMAT_OFF_T "%ld" # define CURL_SIZEOF_CURL_OFF_T 8 # define CURL_SUFFIX_CURL_OFF_T L # define CURL_SUFFIX_CURL_OFF_TU UL # elif defined(__EABI__) /* Treat all ARM compilers equally */ # define CURL_SIZEOF_LONG 4 # define CURL_TYPEOF_CURL_OFF_T long long # define CURL_FORMAT_CURL_OFF_T "lld" # define CURL_FORMAT_CURL_OFF_TU "llu" # define CURL_FORMAT_OFF_T "%lld" # define CURL_SIZEOF_CURL_OFF_T 8 # define CURL_SUFFIX_CURL_OFF_T LL # define CURL_SUFFIX_CURL_OFF_TU ULL # endif # define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t # define CURL_SIZEOF_CURL_SOCKLEN_T 4 # define CURL_PULL_SYS_TYPES_H 1 # define CURL_PULL_SYS_SOCKET_H 1 |
BUILD_CURL_TEST -> FALSE CURL_DISABLE_LDAP -> TRUE CURL_DISABLE_LDAPS -> TRUE CMAKE_C_FLAGS -> -D__GNUC__ -D__EABI__ -DHAVE_GLIBC_STRERROR_R=1 CMAKE_EXE_LINKER_FLAGS -> -nostdlib -Wl,-rpath-link=/cygdrive/c/Programs/android-ndk-r3/build/platforms/android-5/arch-arm/usr/lib -L/cygdrive/c/Programs/android-ndk-r3/build/platforms/android-5/arch-arm/usr/lib -lc /cygdrive/c/Programs/android-ndk-r3/build/platforms/android-5/arch-arm/usr/lib/crtbegin_dynamic.o CMAKE_MODULE_LINKER_FLAGS , CMAKE_SHARED_LINKER_FLAGS -> -nostdlib -Wl,-rpath-link=/cygdrive/c/Programs/android-ndk-r3/build/platforms/android-5/arch-arm/usr/lib -L/cygdrive/c/Programs/android-ndk-r3/build/platforms/android-5/arch-arm/usr/lib -lc |