2012-02-09 189 views
7

我想使用Cygwin为Android交叉编译ICU静态库。到目前为止,我已经能够配置和制作Cygwin/MSVC和Cygwin版本。我已经安装了android-ndk-r7,并且可以在工具链目录中看到gcc的一个版本。几个例子表明使用主机:arm-eabi - 但这并不存在于我的机器上。使用arm-linux-androideabi-4.4.3编译ICU

我抄MH-linux的MH-不明/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 \预建\ WINDOWS \ ARM-Linux的androideabi \ BIN?我是否缺少一些设置或安装?我应该设置我的路径,以便发现第一个gccarm-linux-androiedeabi

更新1我刚才注意到,虽然窗户\ ARM-Linux的= androideabi \ BIN包含GCCWINDOWS \斌包含ARM-Linux的androideabi-GCC。我如何让ICU调用它?

更新2.在史蒂芬R.卢米斯的建议下,我拿起了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 /工具链/掰Linux的androideabi-4.4.3 /预建/窗/ bin中到我的道路,并重新运行配置与主机=在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中。 -L后额外的空间在原有的LDFLAGS,但除去这并没有帮助。

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

"The windows ndk toolchain is (thankfully) native to windows, so it doesnt go through the cygwin translation layer which would translate /cygdrive paths."

更新5被交换的/所有实例cygdrive/d/with 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:/有帮助,但后来会导致失败,因为它是Cygwin制作的。

Linux - 使用正常的NDK r7版本,配置将失败,并出现wchar_t = 0错误。 Crystax NDK内部版本将解决这个问题,并使得在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 

帮助!

+0

我在这里采取了戳。你错过了一个图书馆。看起来像你的C编译器无法为目标架构构建。过时的构建脚本等 – Vangel 2012-02-09 22:07:28

+0

@Vangel在这一点上,正是这样。 arm-linux-androideabi-gcc正在寻找-lc(libc.so),它位于/ cygdrive/d/Projects/android-ndk-r7/platforms/android-8/arch-arm/lib /中-L)但以某种方式无法找到它。试图在脚本之外复制,但不知道在哪里可以找到conftest.c – tofutim 2012-02-09 22:30:56

+0

难道是arm-linux-androideabi-gcc无法理解cygwin路径吗? – tofutim 2012-02-09 22:35:10

回答

4

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

例如install d:\android-r9b

01.下载安装例如d:\msys MSyshttp://www.mingw.org/wiki/MSYS 1.01

下载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

如果使用窗口64 7/8添加额外的选项: - system=windowx86_64

出口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 

make

所有成功

+0

,如果有错误找不到langinfo.h错误。 你可以下载它: http://ftp.cc.uoc.gr/mirrors/OpenBSD/src/include/下载langinfo.hand nl_types.h保存到/ d/ic/source/common – 2013-12-26 13:41:07

+0

因为这是你的第一个答案,请观察我的编辑,看看如何正确回答。欢迎来到SO和快乐编码! – 2013-12-26 14:07:43

+0

这些步骤非常有帮助。我不得不添加'''RANLIB = arm-linux-androideabi-ranlib'''到第11步,然后才能成功构建它。 – Bellinghammer 2014-06-05 00:12:07