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

时间:2012-02-09 20:56:58

标签: android configure icu

我想使用Cygwin交叉编译Android的ICU静态库。到目前为止,我已经能够配置和制作Cygwin / MSVC和Cygwin版本。我已经安装了android-ndk-r7,可以在toolchains目录中看到一个版本的gcc。有几个例子建议使用host: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 \ toolchains \ arm-linux-androideabi-4.4.3 \ prebuilt \ windows \ arm下的gcc -linux-androideabi \ BIN?我错过了一些设置还是安装?我应该设置我的PATH,以便找到第一个 gcc arm-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-重新运行configure 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。根据http://groups.google.com/group/android-ndk/browse_thread/thread/46295616a889bc12

中较旧的帖子
  

“windows ndk工具链(谢天谢地)是Windows原生的,所以它   不会通过将翻译的cygwin翻译层   / cygdrive paths。“

更新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.

更新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。更改了我的路径,以便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

似乎必须要发生的是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失败。见ICU library in Android NDK。您可以强制定义它,这将导致另一个有关大小不匹配的错误。

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

icu/source/common/ustrenum.cpp:118: error: must #include <typeinfo> before using typeid

帮助!

1 个答案:

答案 0 :(得分: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 versin 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

如果使用窗口7/8 64位添加其他选项: - system=windowx86_64

10。再次导出PATH; export 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

12。 make

一切都很成功