使用arm-linux-androideabi-4.4.3编译ICU

tof*_*tim 7 android configure icu

我想使用Cygwin交叉编译Android的ICU静态库.到目前为止,我已经能够配置和制作Cygwin/MSVC和Cygwin版本.我已经安装了android-ndk-r7,可以在toolchains目录中看到一个版本的gcc.几个例子建议使用host:arm-eabi - 但这在我的机器上不存在.

我已经在/ icu/source/config中将mh-linux复制到mh-unknown并运行以下命令:

export HOST_ICU=/cygdrive/d/__/External/SQLite/icu
export ICU_CROSS_BUILD=/cygdrive/d/__/External/SQLite/icu-cygwin
export NDK_ROOT=/cygdrive/d/__/android-ndk-r7
export CPPFLAGS="-I$NDK_ROOT/platforms/android-8/arch-arm/usr/include/ -O3 -fno-short-wchar -DU_USING_ICU_NAMESPACE=0 -DU_GNUC_UTF16_STRING=0 -fno-short-enums -nostdlib"
export CXXFLAGS="-I$NDK_ROOT/platforms/android-8/arch-arm/usr/include/ -O3 -fno-short-wchar -DU_USING_ICU_NAMESPACE=0 -DU_GNUC_UTF16_STRING=0 -fno-short-enums -nostdlib"
export CFLAGS="-I$NDK_ROOT/platforms/android-8/arch-arm/usr/include/ -O3 -fno-short-wchar -DU_USING_ICU_NAMESPACE=0 -DU_GNUC_UTF16_STRING=0 -fno-short-enums -nostdlib"
export LDFLAGS="-lc -Wl,-rpath-link=$NDK_ROOT/platforms/android-8/arch-arm/usr/lib/ -L $NDK_ROOT/platforms/android-8/arch-arm/usr/lib/"

$HOST_ICU/source/configure --with-cross-build=$ICU_CROSS_BUILD --enable-extras=no --enable-strict=no --enable-static --enable-shared=no --enable-tests=no --enable-samples=no --enable-dyload=no --enable-tools=no --host=arm-eabi --with-data-packaging=archive
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

checking for ICU version numbers... release 4.8.1.1, library 48.1.1, unicode version 6.0
checking build system type... i686-pc-cygwin
checking host system type... arm-unknown-eabi
checking target system type... arm-unknown-eabi
checking whether to build debug libraries... no
checking whether to build release libraries... yes
checking for arm-eabi-gcc... no
checking for gcc... gcc
checking whether the C compiler works... no
configure: error: in `/cygdrive/d/Projects/__/External/SQLite/icu-android':
configure: error: C compiler cannot create executables
See `config.log' for more details
Run Code Online (Sandbox Code Playgroud)

我确定这是一个"愚蠢"的问题,但是如何让ICU配置脚本指向$ NDK_ROOT\toolchains\arm-linux-androideabi-4.4.3\prebuilt\windows\arm-linux-下的gcc androideabi\BIN?我错过了一些设置还是安装?我应该设置我的PATH,以便找到的第一个gccarm-linux-androiedeabi中的那个吗?

更新1.我刚注意到,虽然windows\arm-linux = androideabi\bin包含gcc,但windows\bin包含arm-linux-androideabi-gcc.我如何让ICU给它打电话?

更新2.根据Steven R. Loomis的建议,我从中获取了config.sub和config.guess的更新

http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD http://git.savannah.gnu.org/gitweb/?p = config.git; A = blob_plain; F =的config.guess; HB = HEAD

android-ndk-r7/toolchains/arm-linux-androideabi-4.4.3/prebuilt/windows/bin放到我的路径中,然后用--host = arm-linux-androideabi重新运行configure ...这一次:

checking for arm-linux-androideabi-gcc... arm-linux-androideabi-gcc
checking whether the C compiler works... no
Run Code Online (Sandbox Code Playgroud)

绝对更接近.config.log中的详细错误

gcc version 4.4.3 (GCC)
configure:3125: $? = 0
configure:3114: arm-linux-androideabi-gcc -V >&5
arm-linux-androideabi-gcc.exe: '-V' option must have argument
configure:3125: $? = 1
configure:3114: arm-linux-androideabi-gcc -qversion >&5
arm-linux-androideabi-gcc.exe: unrecognized option '-qversion'
arm-linux-androideabi-gcc.exe: no input files
configure:3125: $? = 1
configure:3145: checking whether the C compiler works
configure:3167: arm-linux-androideabi-gcc -I/cygdrive/d/Projects/android-ndk-r7/platforms/android-8/arch-arm/usr/include
/ -O3 -fno-short-wchar -DU_USING_ICU_NAMESPACE=0 -DU_GNUC_UTF16_STRING=0 -fno-short-enums -nostdlib -I/cygdrive/d/Projec
ts/android-ndk-r7/platforms/android-8/arch-arm/usr/include/ -O3 -fno-short-wchar -DU_USING_ICU_NAMESPACE=0 -DU_GNUC_UTF1
6_STRING=0 -fno-short-enums -nostdlib -lc -Wl,-rpath-link=/cygdrive/d/Projects/android-ndk-r7/platforms/android-8/arch-a
rm/usr/lib/ -L /cygdrive/d/Projects/android-ndk-r7/platforms/android-8/arch-arm/usr/lib/ conftest.c  >&5
D:/Projects/android-ndk-r7/toolchains/arm-linux-androideabi-4.4.3/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/
4.4.3/../../../../arm-linux-androideabi/bin/ld.exe: cannot find -lc
collect2: ld returned 1 exit status
configure:3171: $? = 1
configure:3209: result: no
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME ""
| #define PACKAGE_TARNAME ""
| #define PACKAGE_VERSION ""
| #define PACKAGE_STRING ""
| #define PACKAGE_BUGREPORT ""
| #define PACKAGE_URL ""
| /* end confdefs.h.  */
|
| int
| main ()
| {
|
|   ;
|   return 0;
| }
configure:3214: error: in `/cygdrive/d/Projects/__/External/SQLITE/icu-android':
configure:3216: error: C compiler cannot create executables
See `config.log' for more details
Run Code Online (Sandbox Code Playgroud)

更新3.对config.sub和config.guess的更改起作用,我们现在正在使用正确的gcc编译器.-lc失败来自于无法找到libc.so(在android-ndk-r7/platforms/android-8/arch-arm/usr/lib中),即使这是在LDFLAGS中.我确实有原始LDFLAGS中-L之后的额外空间,但删除它没有帮助.

更新4.根据http://groups.google.com/group/android-ndk/browse_thread/thread/46295616a889bc12中较旧的帖子

"windows ndk工具链(谢天谢地)是Windows原生的,因此它不会通过cygwin转换层来转换/ cygdrive路径."

更新5.使用D:/交换/ cygdrive/d /的所有实例.现在C编译器工作,虽然它仍然没有.怀疑ICU_CROSS_BUILD必须位于icu/source目录中.

checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... yes
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether arm-linux-androideabi-gcc accepts -g... yes
checking for arm-linux-androideabi-gcc option to accept ISO C89... none needed
checking for arm-linux-androideabi-g++... arm-linux-androideabi-g++
checking whether we are using the GNU C++ compiler... yes
checking whether arm-linux-androideabi-g++ accepts -g... yes
checking how to run the C preprocessor... arm-linux-androideabi-gcc -E
checking for a BSD-compatible install... /usr/bin/install -c
checking for gmake... /usr/bin/gmake
configure: error: D:/Projects/__/External/SQLite/icu-cygwin/config/icucross.mk not found. Please build ICU in
 D:/Projects/__/External/SQLite/icu-cygwin first.
Run Code Online (Sandbox Code Playgroud)

更新6.我在icu-cygwin中重新配置并编译了我的Cygwin文件夹.去图,这次icucross.mk在那里.配置成功!但...

更新7 Make没有那么好.

$ make
D:/Projects/__/External/SQLite/icu/source/config/mh-linux:41: *** target pattern contains no `%'.  Stop.
Run Code Online (Sandbox Code Playgroud)

什么?!?!看来现在我们再次想要Cygwin路径...... :(

更新8.更改了我的路径,以便HOST_ICU和ICU_CROSS_BUILD使用Cygwin路径,但NDK_ROOT是Windows路径(因为Android NDK ld无法处理cygwin路径).

这是时候了

arm-linux-androideabi-gcc.exe: /cygdrive/d/Projects/__/External/SQLit                                                                 e/icu/source/stubdata/stubdata.c: No such file or directory
arm-linux-androideabi-gcc.exe: no input files
Run Code Online (Sandbox Code Playgroud)

似乎必须要发生的是arm-linux-androideabi-gcc需要为cygwin制作,否则交叉构建将无效.

更新9.似乎arm-linux-androideabi-gcc不支持cygwin路径 - 尽管ndk_build确实如此.但是,ICU设置为调用arm-linux-androideabi-gcc而"make"需要cygwin路径.也许是时候切换到OSX或Linux来做到这一点.

更新10 - 仍然没有成功. Cygwin - 显然arm-linux-androideabi Crystax构建也不支持-L中的cygwin路径.尝试在Cygwin下进行交叉编译会产生-lc错误,因为它无法解析库的-L/cygdrive/d/...路径.更改为D:/有帮助,但后来导致make失败,因为它是Cygwin make.

Linux - 使用正常的NDK r7构建,配置将失败并出现wchar_t = 0错误.Crystax NDK构建将修复此问题,并且make会在Android的sys/type.h中抱怨uint64_t失败.请参阅Android NDK中的ICU库.您可以强制定义它,这将导致另一个关于大小不匹配的错误.

OSX - 可能是最成功的,使用官方版本或Crystax构建编译,它直接导致uint64_t错误.如果你破解它,它将引导你

icu/source/common/ustrenum.cpp:118: error: must #include <typeinfo> before using typeid
Run Code Online (Sandbox Code Playgroud)

救命!

小智 4

00.下载android ndk http://developer.android.com/tools/sdk/ndk/index.html

例子install d:\android-r9b

01.下载安装示例d:\msys MSys http://www.mingw.org/wiki/MSYS 1.01

02.下载gcc 3.8.1 w64 http://mingw-w64.sourceforge.net/示例安装d:\mingw32_64

03.下载icu版本52.1 http://site.icu-project.org/download/52#TOC-ICU4C-Download

04.提取icu源代码到d:\icu

05.输入msys 使用export PATH=/d/msys/1.0/bin:/d/ming32_64/mingw32/bin:$PATH

06. cd /d/icu;mkdir mingw;mkdir android;cd mingw

这是遵循 icu readme.html 交叉编译步骤

07. cd /d/icu/ming ;../source/runConfigureICU MinGW ;make

没问题,一切正常,并且正在/d/icu/mingw/bin生成稍后交叉编译的工具。

08. cd /d/icu/android

09. /d/android-ndk-r9b/build/tools/make-standalone-toolchain.sh --platform=android-9 --install-dir=/d/androidgcc/ -- toolchain=arm-linux-androideabi-4.8

如果使用 Windows 7/8 64 位添加附加选项:--system=windowx86_64

10.再次导出PATHexport PATH=/d/msys/1.0/bin/:/d/androidgcc/bin/:/d/androidgcc/arm-linux-androideabi/bin/

该路径必须包含ar.exe创建库的执行。

11.创建共享库。

sh ../source/configure --host=armv6-google-linux --enable-shared=yes --disable-static -with-cross-build=/d/icu/mingw CC=arm-linux-androideabi-gcc CXX=arm-linux-androideabi-g++ AR=arm-linux-androideabi-ar --with-data-packaging=archive
Run Code Online (Sandbox Code Playgroud)

12. make

一切顺利