(OK) 编译libiconv-1.14(静态库)—CentOS 7— android-ndk

Posted ztguang_张同光

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了(OK) 编译libiconv-1.14(静态库)—CentOS 7— android-ndk相关的知识,希望对你有一定的参考价值。

+++++++++++++编译libiconv-1.14 (静态库)


export NDK_ROOT="/opt/android-on-linux/android-ndk-r10d"

export TOOLCHAIN="$NDK_ROOT/platforms/android-21/arch-arm"

export ARMVERSION=7

export SYSROOT="$TOOLCHAIN"

export CFLAGS="--pipe --sysroot=$SYSROOT -I$NDK_ROOT/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.9/include-fixed -I$NDK_ROOT/platforms/android-21/arch-arm/usr/include"

export CPPFLAGS="$CFLAGS"

export CXXFLAGS="$CFLAGS"

export LDFLAGS="--sysroot=$SYSROOT -L$SYSROOT/usr/lib/ -L$NDK_ROOT/sources/cxx-stl/stlport/libs/armeabi-v7a -L/opt/cBPM-android/criteria-lin/lib -lstlport_static -lgcc -lc -liconv"

export CPATH="$NDK_ROOT/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin"

export CPP="$CPATH/arm-linux-androideabi-cpp"

export CXX="$CPATH/arm-linux-androideabi-g++"

export CC="$CPATH/arm-linux-androideabi-gcc"

export LD="$CPATH/arm-linux-androideabi-ld"

export AR="$CPATH/arm-linux-androideabi-ar"



编译命令:gl_cv_header_working_stdint_h=yes ./configure --host=arm-linux-androideabi

错误:configure: error: /bin/sh build-aux/config.sub arm-linux-androideabi failed

//You might need a newer config.sub and config.guess, 2010-05-20 or later.

//You can obtain the newest version of config.guess and config.sub from the ‘config’ project at http://savannah.gnu.org/. The commands to fetch them are

$ wget -O config.guess http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD

$ wget -O config.sub http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD

或者:

[root@localhost libiconv-1.14]# locate config.guess

/opt/gcc-4.9.0/config.guess

[root@localhost libiconv-1.14]# cp /opt/gcc-4.9.0/config.guess /opt/gcc-4.9.0/config.sub build-aux/

[root@localhost libiconv-1.14]# cp /opt/gcc-4.9.0/config.guess /opt/gcc-4.9.0/config.sub libcharset/build-aux/



[root@localhost libiconv-1.14]# pwd

/opt/cBPM-android/libiconv-1.14

[root@localhost libiconv-1.14]# cp config.guess config.sub build-aux/

[root@localhost libiconv-1.14]# cp config.guess config.sub libcharset/build-aux/

[root@localhost libiconv-1.14]# gl_cv_header_working_stdint_h=yes ./configure --host=arm-linux-androideabi

[root@localhost libiconv-1.14]# gl_cv_header_working_stdint_h=yes ./configure --host=arm-linux-androideabi --enable-static --disable-shared

[root@localhost libiconv-1.14]# make -j5

[root@localhost libiconv-1.14]# find . -name libiconv.a

./lib/.libs/libiconv.a


//复制库文件(arm)

[root@localhost libiconv-1.14]# cp ./lib/.libs/libiconv.a /opt/cBPM-android/criteria-lin/lib

[root@localhost libiconv-1.14]# cp ./lib/.libs/libiconv.so* /opt/cBPM-android/criteria-lin/lib

[root@localhost libiconv-1.14]# cp /usr/lib64/libWorkflowEngineD.so /opt/cBPM-android/criteria-lin/lib

[root@localhost libiconv-1.14]# cp /usr/lib64/libLibraries.so /opt/cBPM-android/criteria-lin/lib


+++++++++++++编译Criteria.Tools.Executor错误

/opt/cBPM-android/criteria-lin/lib/libxerces-c.a(IconvTransService.o):IconvTransService.cpp:function xercesc_3_1::IconvLCPTranscoder::calcRequiredSize(char const*, xercesc_3_1::MemoryManager*): error: undefined reference to __ctype_get_mb_cur_max


解决方法:+++++++++++++ 在上面基础上,编译libiconv (静态库)

這似乎是NDK的BUG,在stdlib.h內有宣告出__ctype_get_mb_cur_max函數,但是卻沒有去實作它。如果出現這個問題,不建議直接修改NDK,要到libiconv目錄下,修改「libcharset/lib」目錄裡的「localcharset.c」檔案,在檔案最下面加上以下程式碼即可。


[root@localhost libiconv-1.14]# gedit /opt/cBPM-android/libiconv-1.14/libcharset/lib/localcharset.c


size_t __ctype_get_mb_cur_max(void)

    return 1;

保存,重新编译libiconv (静态库)


[root@localhost libiconv-1.14]# nm ./lib/.libs/libiconv.a |grep ctype_get_mb_cur_max

         U __ctype_get_mb_cur_max

0000060c T __ctype_get_mb_cur_max


//如果您指定了 -A 选项,则 nm 命令只报告与该文件有关的或者库或者对象名。

[root@localhost libiconv-1.14]# nm -A ./lib/.libs/libiconv.a|grep ctype_get_mb_cur_max

./lib/.libs/libiconv.a:iconv.o:         U __ctype_get_mb_cur_max

./lib/.libs/libiconv.a:localcharset.o:0000060c T __ctype_get_mb_cur_max

[root@localhost libiconv-1.14]#


[root@localhost criteria-lin]#  nm -A lib/lib* |grep ctype_get_mb_cur_max

nm: lib/libc.so:无符号

lib/libiconv.a:iconv.o:         U __ctype_get_mb_cur_max

lib/libiconv.a:localcharset.o:0000060c T __ctype_get_mb_cur_max

lib/libiconv.so:         U __ctype_get_mb_cur_max

lib/libiconv.so.2:         U __ctype_get_mb_cur_max

lib/libiconv.so.2.5.1:         U __ctype_get_mb_cur_max

nm: lib/libsqlite.so:无符号

nm: lib/libstdc++.so:无符号

lib/libxerces-c-3.1.so:         U __ctype_get_mb_cur_max

lib/libxerces-c.a:IconvTransService.o:         U __ctype_get_mb_cur_max


所以,编译Criteria.Tools.Executor时,需要 静态链接 /opt/cBPM-android/criteria-lin/lib/libiconv.a



以上是关于(OK) 编译libiconv-1.14(静态库)—CentOS 7— android-ndk的主要内容,如果未能解决你的问题,请参考以下文章

libiconv库的安装和使用

安装libiconv出错

Deepin 15.3 编译安装 LNMP(PHP5.6.31)

(OK) 编译xerces-c-3.1.2(静态库)—CentOS 7— android-ndk

OpenCV静态库编译与链接

C/C++编译问题,静态库,动态库。