我想使用 Cygwin 交叉编译 Android 的 ICU 静态库。到目前为止,我已经能够配置和制作 Cygwin/MSVC 和 Cygwin 版本。我已经安装了android-ndk-r7,并且可以在toolchains目录中看到gcc的版本。有几个例子建议使用 host:arm-eabi - 但这在我的机器上不存在。
我已经复制了mh-linux to mh-未知 in /icu/源/配置并运行以下命令:
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-linux- 下的 gcc androideabi\bin?我是否缺少一些设置或安装?我应该设置我的路径以便第一个gcc找到的是其中的一个ARM-Linux-Androideabi?
更新1。我刚刚注意到windows\arm-linux=androideabi\bin包含gcc, 窗口\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.sub;hb=HEAD
http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
placed android-ndk-r7/toolchains/arm-linux-androideabi-4.4.3/prebuilt/windows/bin进入我的路径,并使用 --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。根据较旧的帖子http://groups.google.com/group/android-ndk/browse_thread/thread/46295616a889bc12 http://groups.google.com/group/android-ndk/browse_thread/thread/46295616a889bc12
“Windows NDK 工具链(幸运的是)是 Windows 原生的,所以它
不通过 cygwin 翻译层进行翻译
/cygdrive 路径。”
更新5。将 /cygdrive/d/ 的所有实例交换为 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 就在那里。配置成功!但...
Update 7 Make结局并没有那么好。
$ 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。看Android NDK 中的 ICU 库 https://stackoverflow.com/questions/4168962/icu-library-in-android-ndk/9224077#9224077。您可以强制定义它,这将导致另一个有关大小不匹配的错误。
OSX- 可能是最成功的,使用官方构建或 Crystax 构建进行编译,它直接导致 uint64_t 错误。如果你绕过它,它会引导你
icu/source/common/ustrenum.cpp:118: error: must #include <typeinfo> before using typeid
Help!