(OK) 编译xerces-c-3.1.2(动态库)—CentOS 7— android-ndk
export XERCES="/opt/cBPM-android/xerces-c-3.1.2/"
export NDK="/opt/android-on-linux/android-ndk-r10d/"
export SYSROOT="$NDK/platforms/android-21/arch-arm"
export CC="$NDK/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc"
export CXX="$NDK/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-g++"
export CFLAGS="--sysroot=$SYSROOT"
export LDFLAGS="--sysroot=$SYSROOT -nostdlib -L$NDK/sources/cxx-stl/stlport/libs/armeabi-v7a -L$SYSROOT/usr/lib -L/opt/cBPM-android/criteria-lin/lib -liconv -lstdc++ -lstlport -lc"
export CPPFLAGS="-fPIC -I$NDK/sources/cxx-stl/stlport/stlport -I$NDK/platforms/android-21/arch-arm/usr/include -I$NDK/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/include -I$NDK/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.9/include-fixed -I$NDK/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.9/include -I$XERCES/src/xercesc/xinclude -I$XERCES/tests/src/xinclude -I$XERCES/tests/src/xinclude/tests/xinclude"
// -nostdlib -Xlinker -R$SYSROOT/usr/lib $SYSROOT/usr/lib/crtbegin_static.o $SYSROOT/usr/lib/crtend_android.o
// ls /opt/android-on-linux/android-ndk-r10d/sources/cxx-stl/stlport/libs/armeabi-v7a
// libstlport_shared.so libstlport.so libstlport_static.a thumb
[root@localhost xerces-c-3.1.2]# ./configure --host=arm-linux-androideabi --enable-static --disable-shared --enable-transcoder-iconv
错误:configure: error: Xerces cannot function without a transcoder
解决方法如下:
//编译静态库
[root@localhost xerces-c-3.1.2]# ac_cv_func_iconv_open=yes ac_cv_func_iconv_close=yes ac_cv_func_mblen=yes ac_cv_func_wcstombs=yes ac_cv_func_mbstowcs=yes ac_cv_func_iconv=yes ./configure --host=arm-linux-androideabi --enable-static --disable-shared --enable-transcoder-iconv
[root@localhost xerces-c-3.1.2]# make -j5
//编译动态库
[root@localhost xerces-c-3.1.2]# gl_cv_header_working_stdint_h=yes ac_cv_func_iconv_open=yes ac_cv_func_iconv_close=yes ac_cv_func_mblen=yes ac_cv_func_wcstombs=yes ac_cv_func_mbstowcs=yes ac_cv_func_iconv=yes ./configure --host=arm-linux-androideabi --enable-transcoder-iconv
[root@localhost xerces-c-3.1.2]# make -j5
错误及解决方法:
错误:
xercesc/util/PlatformUtils.cpp:713:4: error: #error No timing support is configured for this platform.
stricmp.c:37:3: error: #error Need implementation of stricmp compatibility function
strnicmp.c:37:3: error: #error Need implementation of strnicmp compatibility function
解决方法,在 config.h 加下面一行
#define HAVE_GETTIMEOFDAY 1
#define HAVE_STRCASECMP 1
#define HAVE_STRNCASECMP 1
错误:
towupper.h conflicting declaration of C function 'int towupper(int)'
解决方法
towlower.h、towupper.h注释如下:
//extern int towlower(int wc);
//extern int towupper(int wc);
错误:
arm-linux-androideabi-g++: error: crtbegin_so.o: No such file or directory
arm-linux-androideabi-g++: error: crtend_so.o: No such file or directory
原因是ld找不到 crtbegin_so.o 和 crteng_so.o,
解决方法,在项目源码下面建立软连接
ln -s /opt/android-on-linux/android-ndk-r10d/platforms/android-21/arch-arm/usr/lib/crtbegin_so.o src
ln -s /opt/android-on-linux/android-ndk-r10d/platforms/android-21/arch-arm/usr/lib/crtend_so.o src
//成功编译动态库
[root@localhost xerces-c-3.1.2]# find . -name libxerces-c-3.1.so
./src/.libs/libxerces-c-3.1.so
//复制库文件(arm)
[root@localhost xerces-c-3.1.2]# cp ./src/.libs/libxerces-c-3.1.so /opt/cBPM-android/criteria-lin/lib
阅读(2028) | 评论(0) | 转发(0) |