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

使用arm-linux-androideabi-4.4.3编译ICU,android,configure,icu,Android,Configure,Icu,我想使用Cygwin交叉编译Android的ICU静态库。到目前为止,我已经能够配置并制作Cygwin/MSVC和Cygwin版本。我已经安装了android-ndk-r7,可以在toolchains目录中看到gcc的一个版本。有几个例子建议使用主机:arm eabi——但我的机器上没有 我已将mh linux复制到/icu/source/config中的mh unknown,并运行以下程序: export HOST_ICU=/cygdrive/d/__/External/SQLite/icu

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

我已将mh linux复制到/icu/source/config中的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
我得到以下错误:

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
我确信这是一个“愚蠢”的问题,但我如何让ICU配置脚本指向$NDK_ROOT\toolschains\arm-linux-androidabi-4.4.3\prebuild\windows\arm-linux-androidabi\bin下的gcc?我是否缺少一些设置或安装?我是否应该设置路径,以便找到的第一个gcc就是armlinux和androiedeabi中的gcc

更新1。我刚刚注意到,虽然windows\arm linux=androideabi\bin包含gcc,但windows\bin包含arm linux androideabi gcc。我怎么才能让重症监护室给这个打电话

更新2。根据Steven R.Loomis的建议,我从

将android-ndk-r7/toolschains/arm-linux-androideabi-4.4.3/prebuild/windows/bin放入我的路径中,然后重新运行configure with--host=arm-linux-androideabi。。。这次:

checking for arm-linux-androideabi-gcc... arm-linux-androideabi-gcc
checking whether the C compiler works... no
肯定更近了。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
更新3。对config.sub和config.guess的更改有效,因为我们现在使用的是正确的gcc编译器。-lc失败源于无法找到libc.so(在android-ndk-r7/platforms/android-8/arch-arm/usr/lib中),尽管它在LDFLAGS中。我在原始LDFLAGS中的-L后面确实有一个额外的空格,但删除它并没有帮助

更新4。根据

“windows ndk工具链(谢天谢地)是windows固有的,因此 不经过cygwin翻译层,该层将进行翻译 /cygdrive路径。“

更新5。已将/cygdrive/d/的所有实例与d:/交换。现在,C编译器可以工作,但仍然无法生成。请怀疑ICU交叉构建必须位于ICU/源目录中

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.
更新6。我重新配置并在icu Cygwin中构建了我的Cygwin文件夹。如图所示,这次icucross.mk在那里。配置成功!但是

更新7制作的结果不太好

$ make
D:/Projects/__/External/SQLite/icu/source/config/mh-linux:41: *** target pattern contains no `%'.  Stop.
什么?!看来我们又想要Cygwin路了(

更新8。更改了我的路径,以便主机ICU和ICU交叉构建使用Cygwin路径,但NDK根目录是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
看来必须要做的是,需要为cygwin制作arm-linux Androidabi gcc,否则交叉构建将无法工作

更新9。看起来arm linux Androidabi gcc不支持cygwin路径——尽管ndk_build支持。但是,ICU设置为调用arm linux Androidabi gcc,而“make”需要cygwin路径。也许是时候切换到OSX或linux来实现这一点了

更新10-仍然没有成功。 Cygwin-显然,arm linux Androidabi 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。请参见。您可以强制定义它,这将导致另一个关于大小不匹配的错误

OSX-可能是最成功的,使用官方版本或Crystax版本编译,它直接导致uint64_t错误。如果你绕过它,它将导致你

icu/source/common/ustrenum.cpp:118: error: must #include <typeinfo> before using typeid
icu/source/common/ustreum.cpp:118:错误:必须在使用typeid之前包含

帮助!

00。下载android ndk

示例
安装d:\android-r9b

01。下载安装示例
d:\msys-msys
1.01

02.下载gcc 3.8.1 w64示例安装
d:\mingw32\u 64

03.下载icu版本52.1

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

05.输入
msys
使用
导出路径=/d/msys/1.0/bin:/d/ming32\u 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\u 64

10.export
PATH
再次;
export PATH=/d/msys/1.0/bin/:/d/androidgcc/bin/:/d/androidgcc/arm-linux-androidabi/bin/

路径必须包括创建库的
ar.exe
execute

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
12.
make


一切都成功了

我在这里试探一下。你缺少一个库。似乎你的C编译器无法为目标体系结构构建。过时的构建脚本等@Vangel在这一点上正是如此。arm linux AndroidABI gcc正在寻找-lc(libc.so),它位于/cygdrive/d/Projects/android-ndk-r7/platfo中