(OK) 编译cBPM-android—CentOS 7—NDK8—androideabi-4.7— API14
Posted ztguang_张同光
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了(OK) 编译cBPM-android—CentOS 7—NDK8—androideabi-4.7— API14相关的知识,希望对你有一定的参考价值。
宿主机:CentOS 7 + android-ndk-r8e-linux-x86_64.tar.bz2 + arm_linux-androideabi-4.7 + API-14
手机:MB526 + Android 4.4.4 + armv7
[root@localhost android-on-linux]# wget -c https://dl.google.com/android/ndk/android-ndk-r8e-linux-x86_64.tar.bz2
-------------- Build: Debug Win32 in Criteria.Libraries.bOS (compiler: GNU ARM GCC Compiler For Android)---------------
步骤(问题)1:
/usr/include/gnu/stubs.h:7:27: fatal error: gnu/stubs-32.h: No such file or directory
[root@localhost cBPM-android]# ls /usr/include/gnu/stubs
stubs-64.h stubs.h
[root@localhost cBPM-android]#
解决方法: yum install glibc-devel.i686
步骤(问题)2:
/opt/android-on-linux/android-ndk-r8e/sources/cxx-stl/stlport/stlport/limits.h:30:43: error: #include nested too deeply
解决方法: stlport/stlport/limits.h:27: #if defined (_STLP_HAS_INCLUDE_NEXT) 改为 #if !defined (_STLP_HAS_INCLUDE_NEXT)
步骤(问题)3:
-fno-exceptions
解决方法: -fexceptions 开启异常,
不用 Android自带的 libstlport.so,
使用/opt/android-on-linux/android-ndk-r8e/sources/cxx-stl/stlport/libs/armeabi-v7a/libstlport_static.a
Linker Settings: -Wl,-dn -lstlport_static -Wl,-dy
步骤(问题)4:
String/bOSStringUtils.cpp:17:21: error: toupper was not declared in this scope
解决方法: 在String/bOSStringUtils.cpp开头 #include "ctype.h"
步骤(问题)5:
Idioma/ItemInterface.cpp:41:30: error: isdigit was not declared in this scope
解决方法: 在Idioma/ItemInterface.cpp开头 #include "ctype.h"
步骤(问题)6:
/opt/android-on-linux/android-ndk-r8e/toolchains/arm-linux-androideabi-4.7/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.7/../../../../arm-linux-androideabi/bin/ld: error: cannot find -lxerces-c-3.1
解决方法:
http://permalink.gmane.org/gmane.text.xml.xerces-c.user/3834
步骤(问题)7:
+++++++++++++编译libiconv-1.14 (静态库)
[root@localhost libiconv-1.14]# pwd
/opt/cBPM-android/libiconv-1.14
[root@localhost libiconv-1.14]# make clean
export NDK_ROOT="/opt/android-on-linux/android-ndk-r8e"
export SYSROOT="$NDK_ROOT/platforms/android-14/arch-arm"
export CFLAGS="--pipe --sysroot=$SYSROOT -I$NDK_ROOT/toolchains/arm-linux-androideabi-4.7/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.7/include-fixed -I$NDK_ROOT/platforms/android-14/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"
export CPATH="$NDK_ROOT/toolchains/arm-linux-androideabi-4.7/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"
[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
[root@localhost libiconv-1.14]# cp ./lib/.libs/libiconv.a /opt/cBPM-android/criteria-lin/lib
至此,成功编译 libiconv-1.14 静态库
-----------------如果遇到错误,参考下面内容
错误: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]# 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
+++++++++++++编译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-r8e/"
export SYSROOT="$NDK/platforms/android-14/arch-arm"
export CC="$NDK/toolchains/arm-linux-androideabi-4.7/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc"
export CXX="$NDK/toolchains/arm-linux-androideabi-4.7/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-14/arch-arm/usr/include -I$NDK/toolchains/arm-linux-androideabi-4.7/prebuilt/linux-x86_64/include -I$NDK/toolchains/arm-linux-androideabi-4.7/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.7/include-fixed -I$NDK/toolchains/arm-linux-androideabi-4.7/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.7/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-r8e/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-r8e/platforms/android-14/arch-arm/usr/lib/crtbegin_so.o src
ln -s /opt/android-on-linux/android-ndk-r8e/platforms/android-14/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
步骤(问题)8:
+++++++++++++ 在上面基础上,编译xerces-c (静态库)
编译xerces-c (静态库)—CentOS 7— android-ndk
[root@localhost xerces-c-3.1.2]# pwd
/opt/cBPM-android/xerces-c-3.1.2
[root@localhost xerces-c-3.1.2]# make clean
export XERCES="/opt/cBPM-android/xerces-c-3.1.2/"
export NDK_ROOT="/opt/android-on-linux/android-ndk-r8e"
export SYSROOT="$NDK_ROOT/platforms/android-14/arch-arm"
export CFLAGS="--pipe --sysroot=$SYSROOT -I$NDK_ROOT/sources/cxx-stl/stlport/stlport -I$NDK_ROOT/platforms/android-14/arch-arm/usr/include -I$NDK_ROOT/toolchains/arm-linux-androideabi-4.7/prebuilt/linux-x86_64/include -I$NDK_ROOT/toolchains/arm-linux-androideabi-4.7/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.7/include-fixed -I$NDK_ROOT/toolchains/arm-linux-androideabi-4.7/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.7/include"
export CPPFLAGS="$CFLAGS"
export CXXFLAGS="$CFLAGS"
export LDFLAGS="-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"
export CPATH="$NDK_ROOT/toolchains/arm-linux-androideabi-4.7/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"
[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-eabi" --enable-static --disable-shared --enable-transcoder-iconv
[root@localhost xerces-c-3.1.2]# make -j5
[root@localhost xerces-c-3.1.2]# cp ./src/.libs/libxerces-c.a /opt/cBPM-android/criteria-lin/lib
至此,成功编译 xerces-c-3.1.2 静态库
-----------------如果遇到错误,参考下面内容
/opt/android-on-linux/android-ndk-r8e/platforms/android-14/arch-arm/usr/include
/opt/android-on-linux/android-ndk-r8e/sources/cxx-stl/stlport/stlport
/opt/android-on-linux/android-ndk-r8e/sources/cxx-stl/gabi++/include
/opt/android-on-linux/android-ndk-r8e/sources/cxx-stl/gnu-libstdc++/4.7/include
/opt/android-on-linux/android-ndk-r8e/platforms/android-14/arch-arm/usr/lib
/opt/android-on-linux/android-ndk-r8e/sources/cxx-stl/stlport/libs/armeabi-v7a
/opt/android-on-linux/android-ndk-r8e/sources/cxx-stl/gnu-libstdc++/4.7/libs/armeabi
-----------------------
// -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-r8e/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
错误:
xercesc/util/PlatformUtils.cpp:713:4: error: #error No timing support is configured for this platform. You must configure it.
解决方法,在 config.h 加下面一行
#define HAVE_GETTIMEOFDAY 1
#define HAVE_STRCASECMP 1
#define HAVE_STRNCASECMP 1
//成功编译静态库
[root@localhost xerces-c-3.1.2]# find . -name libxerces-c.a
./src/.libs/libxerces-c.a
//复制库文件(arm)
[root@localhost xerces-c-3.1.2]# cp ./src/.libs/libxerces-c.a /opt/cBPM-android/criteria-lin/lib
+++++++++++++编译Criteria.Tools.Executor错误
xercesc/util/XMLAbstractDoubleFloat.cpp:430: error: undefined reference to localeconv
解决方法:+++++++++++++ 在上面基础上,编译xerces-c (静态库)
[root@localhost xerces-c-3.1.2]# pwd
/opt/cBPM-android/xerces-c-3.1.2
[root@localhost xerces-c-3.1.2]# find . -name XMLAbstractDoubleFloat.cpp
./src/xercesc/util/XMLAbstractDoubleFloat.cpp
[root@localhost xerces-c-3.1.2]# gedit ./src/xercesc/util/XMLAbstractDoubleFloat.cpp
// lconv* lc = localeconv();
// char delimiter = *lc->decimal_point;
char delimiter = .; //把localeconv()调用给绕过去了
保存,重新编译xerces-c (静态库)
+++++++++++++
步骤(问题)9:
+++++++++++++编译Criteria.Tools.Executor错误
/opt/android-on-linux/android-ndk-r8e/toolchains/arm-linux-androideabi-4.7/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.7/../../../../arm-linux-androideabi/bin/ld: error: cannot find -lmysqlclient
解决方法: 使用 SQLite 替换 MySQL, CodeBlocks中,Linker Settings:mysqlclient 替换为 sqlite
********---------------------------********
[root@localhost criteria-lin]# gedit ./src/Criteria/Criteria.Libraries.bOS/SQL/bOSSQLConnectionManager.cpp
将
#include "bOSmySQLConnection.h"
#include "bOSmySQLConnectionData.h"
using namespace bOS::SQL::mySQL;
#ifdef _USE_SQLITE3_
#include "bOSSQLiteConnection.h"
#include "bOSSQLiteConnectionData.h"
using namespace bOS::SQL::SQLite3;
#endif
修改为
#ifdef _USE_MYSQL_
#include "bOSmySQLConnection.h"
#include "bOSmySQLConnectionData.h"
using namespace bOS::SQL::mySQL;
#endif
#ifdef _USE_SQLITE3_
#include "bOSSQLiteConnection.h"
#include "bOSSQLiteConnectionData.h"
using namespace bOS::SQL::SQLite3;
#endif
********---------------------------********
[root@localhost criteria-lin]# gedit ./include/bOS/bOSSQLConnectionManager.h
将
enum DataBaseType
ODBC_INTERFACE,
SQLITE3,
MYSQL
;
修改为
enum DataBaseType
CONN,
MYSQL,
ODBC_INTERFACE,
SQLITE3,
FILESYSTEM
;
********---------------------------********
所有 和 MYSQL 相关 代码,使用如下:
#ifdef _MYSQL_
...
#endif
实际只涉及一个文件: ./src/Criteria/Criteria.Libraries.bOS/SQL/bOSSQLConnectionManager.cpp
比较彻底的方法:
[root@localhost criteria-lin]# mv ./include/bOS/mySQL ./include/bOS/mySQL-not-use
[root@localhost criteria-lin]# mv ./src/Criteria/Criteria.Libraries.bOS/SQL/mySQL/ ./src/Criteria/Criteria.Libraries.bOS/SQL/mySQL-not-use
另外,src/Criteria/Criteria.Libraries.bOS/Libraries.bOS.cbp,中删除如下内容:
<Unit filename="SQL/mySQL/bOSmySQLConnection.cpp" />
<Unit filename="SQL/mySQL/bOSmySQLConnection.h" />
<Unit filename="SQL/mySQL/bOSmySQLConnectionData.cpp" />
<Unit filename="SQL/mySQL/bOSmySQLConnectionData.h" />
<Unit filename="SQL/mySQL/bOSmySQLResultSet.cpp" />
<Unit filename="SQL/mySQL/bOSmySQLResultSet.h" />
<Unit filename="SQL/mySQL/bOSmySQLResultSetField.cpp" />
<Unit filename="SQL/mySQL/bOSmySQLResultSetField.h" />
<Unit filename="SQL/mySQL/bOSmySQLResultSetMetaData.cpp" />
<Unit filename="SQL/mySQL/bOSmySQLResultSetMetaData.h" />
步骤(问题)10:
********---------------------------编译参数 设置********codeblocks 全局参数 设置:
【Settings】->【Compiler】->【GNU ARM GCC Compiler For Android】->【Compiler Settings】->【Other options】
空
【Settings】->【Compiler】->【GNU ARM GCC Compiler For Android】->【Compiler Settings】->【#defines】
空
【Settings】->【Compiler】->【GNU ARM GCC Compiler For Android】->【Linker Settings】->【Link libraries】
空
【Settings】->【Compiler】->【GNU ARM GCC Compiler For Android】->【Search directories】->【Compiler】
空
【Settings】->【Compiler】->【GNU ARM GCC Compiler For Android】->【Search directories】->【Linker】
空
【Settings】->【Compiler】->【GNU ARM GCC Compiler For Android】->【Toolchain executable】->【ompiler Installation directory】
/opt/android-on-linux/android-ndk-r8e/toolchains/arm-linux-androideabi-4.7/prebuilt/linux-x86_64/
arm-linux-androideabi-gcc
arm-linux-androideabi-g++
arm-linux-androideabi-g++
arm-linux-androideabi-ar
【Settings】->【Compiler】->【GNU ARM GCC Compiler For Android】->【Build options】->【处理器数】4
********---------------------------******** 全局参数 设置:权宜之计,实现 静态库的编译:
【Settings】->【Compiler】->【GNU ARM GCC Compiler For Android】->【Other Settings】->【Advanced options】->【Commands】->【Link object files to dynamic library】
将
$linker -shared $libdirs $link_objects $link_resobjects -o $exe_output $link_options $libs
修改为
$lib_linker -r -s $static_output $link_objects
********---------------------------******** 全局参数 设置:权宜之计,实现 链接对象顺序的正确,否则,编译Criteria.Tools.Executor出错
【Settings】->【Compiler】->【GNU ARM GCC Compiler For Android】->【Other Settings】->【Advanced options】->【Commands】->【Link object files to console executable】
将
$linker $libdirs -o $exe_output $link_objects $link_resobjects $link_options $libs
修改为
$linker $libdirs -o $exe_output /opt/android-on-linux/android-ndk-r8e/platforms/android-14/arch-arm/usr/lib/crtbegin_static.o $link_objects $link_resobjects $link_options $libs /opt/android-on-linux/android-ndk-r8e/platforms/android-14/arch-arm/usr/lib/crtend_android.o
主要是下面两个文件的位置:
/opt/android-on-linux/android-ndk-r8e/platforms/android-14/arch-arm/usr/lib/crtbegin_static.o
/opt/android-on-linux/android-ndk-r8e/platforms/android-14/arch-arm/usr/lib/crtend_android.o
********---------------------------********
codeblocks 局部参数 设置: Criteria.Libraries.bOS
【Settings】->【Compiler】->【GNU ARM GCC Compiler For Android】->【Compiler Settings】->【Other options】
-W
-O0
-g3
-c
-fmessage-length=0
-fexceptions
默认情况下,GNU工具链编译过程中,控制台输出的一行信息是不换行的,这样,当输出信息过长时(如编译错误时的信息),会导致你无法看到完整的输出信息,加入-fmessage-length=0后,输出信息会根据控制台的宽度自动换行,这样就能看全输出信息了。
【Settings】->【Compiler】->【GNU ARM GCC Compiler For Android】->【Compiler Settings】->【#defines】
_USE_SQLITE3_
SQLITE_OS_UNIX
WIN32
_DEBUG
_WINDOWS
_USRDLL
_CODEMANAGER_TRACE_ON_
BOS_EXPORTS
CODEMANAGER_EXPORTS
ANDROID
【Settings】->【Compiler】->【GNU ARM GCC Compiler For Android】->【Search directories】->【Compiler】
/opt/cBPM-android/criteria-lin/include/bOS/
/opt/android-on-linux/android-ndk-r8e/sources/cxx-stl/stlport/stlport
/opt/android-on-linux/android-ndk-r8e/platforms/android-14/arch-arm/usr/include
【Settings】->【Compiler】->【GNU ARM GCC Compiler For Android】->【Pre/post build steps】->【Post-build steps】
cp /opt/cBPM-android/criteria-lin/bin/Criteria/Debug/bOS/libLibraries.a /opt/cBPM-android/criteria-lin/lib/
右健单击【Criteria.Libraries.bOS】,选择【Properties】,设置见图。
********---------------------------********
codeblocks 局部参数 设置: Criteria.WorkflowEngine
【Settings】->【Compiler】->【GNU ARM GCC Compiler For Android】->【Compiler Settings】->【Other options】
-W
-O0
-g3
-c
-fmessage-length=0
-fexceptions
【Settings】->【Compiler】->【GNU ARM GCC Compiler For Android】->【Compiler Settings】->【#defines】
WIN32
_DEBUG
_WINDOWS
_USRDLL
ENGINE_EXPORTS
WAPI_EXPORTS
_CODEMANAGER_TRACE_ON_
_USE_SQLITE3_
BOS_EXPORTS
【Settings】->【Compiler】->【GNU ARM GCC Compiler For Android】->【Search directories】->【Compiler】
/opt/cBPM-android/criteria-lin/include/WorkflowEngine
/opt/cBPM-android/criteria-lin/include/bOS/
/opt/android-on-linux/android-ndk-r8e/sources/cxx-stl/stlport/stlport
/opt/android-on-linux/android-ndk-r8e/platforms/android-14/arch-arm/usr/include
【Settings】->【Compiler】->【GNU ARM GCC Compiler For Android】->【Pre/post build steps】->【Post-build steps】
cp /opt/cBPM-android/criteria-lin/bin/Criteria/Debug/WorkflowEngine/libWorkflowEngineD.a /opt/cBPM-android/criteria-lin/lib/
右健单击【Criteria.WorkflowEngine】,选择【Properties】,设置见图。
********---------------------------********
codeblocks 局部参数 设置: Criteria.Tools.Executor
【Settings】->【Compiler】->【GNU ARM GCC Compiler For Android】->【Compiler Settings】->【Other options】
-W
-O0
-g3
-c
-fmessage-length=0
-fexceptions
【Settings】->【Compiler】->【GNU ARM GCC Compiler For Android】->【Compiler Settings】->【#defines】
WIN32
_DEBUG
_CONSOLE
_CODEMANAGER_TRACE_ON_
BOS_EXPORTS
ENGINE_EXPORTS
顺序超级重要)》》》》》》》》》》(顺序超级重要)《《《《《《《《《《《《《
codeblocks 局部参数 设置: Criteria.Tools.Executor
【Settings】->【Compiler】->【GNU ARM GCC Compiler For Android】->【Linker Settings】->【Link libraries】
WorkflowEngineD
Libraries
sqlite
xerces-c
iconv
stlport_static
m
gcc
【Settings】->【Compiler】->【GNU ARM GCC Compiler For Android】->【Linker Settings】->【Other linker options】
-static
-nostdlib
-Wl,-dy /opt/cBPM-android/criteria-lin/lib/libdl.so /opt/cBPM-android/criteria-lin/lib/libc.so -Wl,-dn
-Wl,-dy /opt/cBPM-android/criteria-lin/lib/libdl.so -Wl,-dn
【Settings】->【Compiler】->【GNU ARM GCC Compiler For Android】->【Search directories】->【Compiler】
/opt/cBPM-android/criteria-lin/include/bOS/
/opt/cBPM-android/criteria-lin/include/WorkflowEngine
/opt/android-on-linux/android-ndk-r8e/platforms/android-14/arch-arm/usr/include
/opt/android-on-linux/android-ndk-r8e/sources/cxx-stl/stlport/stlport
【Settings】->【Compiler】->【GNU ARM GCC Compiler For Android】->【Search directories】->【Linker】
/opt/cBPM-android/criteria-lin/lib
/opt/android-on-linux/android-ndk-r8e/sources/cxx-stl/stlport/libs/armeabi-v7a
/opt/android-on-linux/android-ndk-r8e/platforms/android-14/arch-arm/usr/lib/
/opt/android-on-linux/android-ndk-r8e/toolchains/arm-linux-androideabi-4.7/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.7/armv7-a/ //libgcc.a
【Settings】->【Compiler】->【GNU ARM GCC Compiler For Android】->【Pre/post build steps】->【Post-build steps】
cp /opt/cBPM-android/criteria-lin/bin/Criteria/Debug/Tools.Executor/executer /opt/cBPM-android/criteria-lin/lib/
右健单击【Criteria.WorkflowEngine】,选择【Properties】,设置见图。
至此,编译Criteria.Tools.Executor成功,具体见 步骤(问题)11:
+++++++++++++编译Criteria.Tools.Executor出错,参考下面内容
error: undefined reference to dlopen
添加链接选项:
-Wl,-dy -ldl -Wl,-dn
-Wl,-dy -lgcc -lc -lstlport_static -lstdc++ -ldl -Wl,-dn
+++++++++++++编译Criteria.Tools.Executor错误:
src/main.cpp:155: error: undefined reference to __cxa_end_cleanup
最后一行: return 0;
修改为: exit(0);
----------------------------
arm-linux-androideabi-g++
-L/opt/cBPM-android/criteria-lin/lib -L/opt/android-on-linux/android-ndk-r8e/sources/cxx-stl/stlport/libs/armeabi-v7a -L/opt/android-on-linux/android-ndk-r8e/platforms/android-14/arch-arm/usr/lib/ -L/opt/android-on-linux/android-ndk-r8e/toolchains/arm-linux-androideabi-4.7/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.7/armv7-a/
-o /opt/cBPM-android/criteria-lin/bin/Criteria/Debug/Tools.Executor/executer
/opt/cBPM-android/criteria-lin/bin/Criteria/Debug/Tools.Executor/src/main.o
-static -nostdlib -Wl,-v -Wl,-dy -lc -ldl -lstlport -lstdc++ -Wl,-dn -lgcc -lsqlite -lxerces-c -lLibraries -lWorkflowEngineD
$linker $libdirs -o $exe_output $link_objects $link_resobjects $link_options $libs
$linker $libdirs -o $exe_output $link_objects $link_resobjects crtbegin_static.o $link_options $libs crtend_android.o
arm-eabi-ld $(LDFLAGS) crtbegin_static.o $(OBJECTS) $(LIBS) crtend_android.o
-Wl,-v -Wl,-dy -lc -ldl -lstlport -lstdc++ -Wl,-dn
+++++++++++++编译Criteria.Tools.Executor错误
CodeManager/CodeItem.cpp:96: error: undefined reference to std::ostrstream::str()
正因为 ostrstream 调用str()后需要自己清除存储空间的不便,才有了后来的ostringstream,对这个问题的改进,我们不必须再负责清除存储空间啦.
+++++++++++++编译Criteria.Tools.Executor错误
bionic/libc/bionic/libc_logging.cpp:165: error: undefined reference to __aeabi_uldivmod
使用手机上的libc.so,不使用静态库
[root@localhost mb526-all-lib]# cp /opt/cBPM-android/mb526-all-lib/libc.so /opt/cBPM-android/criteria-lin/lib/
+++++++++++++编译Criteria.Tools.Executor错误 困扰2天的错误
WAPI/WAPI.cpp:72: error: undefined reference to bOS::XML::XMLHelper::initialize()
WAPI/WAPI.cpp:137: error: undefined reference to bOS::XML::XMLHelper::terminate()
WAPI/WAPIProcess.cpp:37: error: undefined reference to bOS::XML::Data::XMLObject::getXMLString(unsigned int)
WAPI/WAPIProcess.cpp:64: error: undefined reference to bOS::XML::Data::XMLObject::getXMLString(unsigned int)
WAPI/WAPIProcess.cpp:92: error: undefined reference to bOS::XML::Data::XMLObject::getXMLString(unsigned int)
...
engine/Workflow.cpp:175: error: undefined reference to bOS::Collections::Collection::clear()
engine/Workflow.cpp:488: error: undefined reference to bOS::Collections::Collection::clear()
engine/Workflow.cpp:672: error: undefined reference to bOS::Collections::Collection::clear()
ExternalEvent/ManagedEventElement.cpp:73: error: undefined reference to bOS::XML::XMLAttribute::XMLAttribute()
ExternalEvent/ManagedEventElement.cpp:74: error: undefined reference to bOS::XML::XMLAttribute::setName(char const*)
ExternalEvent/ManagedEventElement.cpp:79: error: undefined reference to bOS::XML::XMLAttribute::setValue(char const*)
ExternalEvent/ManagedEventElement.cpp:82: error: undefined reference to bOS::XML::XMLAttribute::setValue(char const*)
ExternalEvent/ManagedEventElement.cpp:85: error: undefined reference to bOS::XML::XMLAttribute::setValue(char const*)
collect2: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 1 second(s))
313 error(s), 0 warning(s) (0 minute(s), 1 second(s))
-----------------------------------
解决方法:(顺序超级重要)(之前順序:Libraries、WorkflowEngineD)》》》》》(顺序超级重要)《《《《《
codeblocks 局部参数 设置: Criteria.Tools.Executor
【Settings】->【Compiler】->【GNU ARM GCC Compiler For Android】->【Linker Settings】->【Link libraries】
WorkflowEngineD
Libraries
sqlite
xerces-c
iconv
stlport_static
m
gcc
【Settings】->【Compiler】->【GNU ARM GCC Compiler For Android】->【Linker Settings】->【Other linker options】
-static
-nostdlib
-Wl,-dy -ldl -lc -Wl,-dn
+++++++++++++编译Criteria.Tools.Executor错误(不用看)
Utils/bOSUniqueID.cpp:22: error: undefined reference to srand
Utils/bOSUniqueID.cpp:38: error: undefined reference to rand
解决方法:
[root@localhost android-ndk-r10d]# gedit platforms/android-21/arch-arm/usr/include/stdlib.h
[root@localhost android-ndk-r10d]# gedit platforms/android-14/arch-arm/usr/include/stdlib.h
srand is defined as inline in: android-19/arch-arm/usr/include/stdlib.h
將定义 放到 android-21/arch-arm/usr/include/stdlib.h
+++++++++++++编译Criteria.Tools.Executor错误
xercesc/util/XMLAbstractDoubleFloat.cpp:430: error: undefined reference to localeconv
參考<<编译xerces-c (静态库)>>
+++++++++++++编译Criteria.Tools.Executor错误
xercesc/util/Transcoders/Iconv/IconvTransService.cpp:238: error: undefined reference to __ctype_get_mb_cur_max
需要 静态链接 /opt/cBPM-android/criteria-lin/lib/libiconv.a
步骤(问题)11:
+++++++++++++编译Criteria.Tools.Executor————成功
arm-linux-androideabi-g++ -W -O0 -g3 -c -fmessage-length=0 -fexceptions -DWIN32 -D_DEBUG -D_CONSOLE -D_CODEMANAGER_TRACE_ON_ -DBOS_EXPORTS -DENGINE_EXPORTS -I/opt/cBPM-android/criteria-lin/include/bOS -I/opt/cBPM-android/criteria-lin/include/WorkflowEngine -I/opt/android-on-linux/android-ndk-r8e/platforms/android-14/arch-arm/usr/include -I/opt/android-on-linux/android-ndk-r8e/sources/cxx-stl/stlport/stlport -c src/main.cpp -o /opt/cBPM-android/criteria-lin/bin/Criteria/Debug/Tools.Executor/src/main.o
arm-linux-androideabi-g++ -L/opt/cBPM-android/criteria-lin/lib -L/opt/android-on-linux/android-ndk-r10d/sources/cxx-stl/stlport/libs/armeabi-v7a -L/opt/android-on-linux/android-ndk-r10d/platforms/android-16/arch-arm/usr/lib/ -L/opt/android-on-linux/android-ndk-r10d/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.6/armv7-a/ -o /opt/cBPM-android/criteria-lin/bin/Criteria/Debug/Tools.Executor/executer /opt/android-on-linux/android-ndk-r8e/platforms/android-14/arch-arm/usr/lib/crtbegin_static.o /opt/cBPM-android/criteria-lin/bin/Criteria/Debug/Tools.Executor/src/main.o -static -nostdlib -Wl,-dy /opt/cBPM-android/criteria-lin/lib/libdl.so /opt/cBPM-android/criteria-lin/lib/libc.so -Wl,-dn -lWorkflowEngineD -lLibraries -lsqlite -lxerces-c -liconv -lstlport_static -lm -lgcc /opt/android-on-linux/android-ndk-r8e/platforms/android-14/arch-arm/usr/lib/crtend_android.o
Output file is /opt/cBPM-android/criteria-lin/bin/Criteria/Debug/Tools.Executor/executer with size 21.75 MB
Running target post-build steps
cp /opt/cBPM-android/criteria-lin/bin/Criteria/Debug/Tools.Executor/executer /opt/cBPM-android/criteria-lin/lib/
Process terminated with status 0 (0 minute(s), 46 second(s))
0 error(s), 305 warning(s) (0 minute(s), 46 second(s))
步骤(问题)12:
+++++++++++++编译Criteria.Tools.Executor————成功———测试
[root@localhost lib]# pwd
/opt/cBPM-android/criteria-lin/lib
[root@localhost lib]# ll executer
-rwxr-xr-x. 1 root root 22830836 9月 25 07:49 executer
[root@localhost lib]# adb root
bash: adb: 未找到命令...
相似命令是: gdb
--------------------------------
[root@localhost platform-tools]# pwd
/opt/android-on-linux/android-sdk-linux/platform-tools
[root@localhost platform-tools]# ls adb
adb
[root@localhost platform-tools]#
将 PATH=$PATH:/opt/android-on-linux/android-sdk-linux/platform-tools 添加到 /root/.bashrc 最后。
[root@localhost lib]# adb root
bash: /opt/android-on-linux/android-sdk-linux/platform-tools/adb: /lib/ld-linux.so.2: bad ELF interpreter: 没有那个文件或目录
[root@localhost lib]# yum install glibc.i686
[root@localhost lib]# adb root
adb: error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directory
[root@localhost lib]# yum install libstdc++.so.6
--------------------------------
[root@localhost lib]# adb root
[root@localhost lib]# adb push executer /data/data
3352 KB/s (22209660 bytes in 6.469s)
[root@localhost lib]# adb root
[root@localhost lib]# adb shell
root@mb526:/ # cd data/data/
root@mb526:/data/data # ./executer
/system/bin/sh: ./executer: No such file or directory
这是因为系统的动态链接器与executer程序中动态链接器的名字或路径不对,执行如下命令:
[root@localhost lib]# pwd
/opt/cBPM-android/criteria-lin/lib
[root@localhost lib]# readelf -l executer
Elf 文件类型为 EXEC (可执行文件)
入口点 0xb138
共有 8 个程序头,开始于偏移量52
程序头:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
PHDR 0x000034 0x00008034 0x00008034 0x00100 0x00100 R 0x4
(OK) 编译xerces-c-3.1.2(动态库)—CentOS 7— android-ndk
VMware 12安装CentOS 6.9时出现:The centos disc was not found in any of your drives.Please insert the cento