2014-07-19 49 views
7

我試圖交叉編譯Freetype 2.5.3,所以我可以將其與我的Android NDK Opengl ES 2項目一起使用,但我不知道該怎麼做。我在Windows上使用Cygwin。我已經搜索了很多關於它的東西,但我仍然需要幫助。交叉編譯適用於Android的Freetype 2.5.3

我出口在Cygwin的一些標誌:

$ export NDK_TOOLCHAIN=/cygdrive/d/Development/Android/ndk-standalone-15 
$ export PATH="$NDK_TOOLCHAIN/bin/:$PATH" 
$ export HOST=arm-linux-androideabi 
$ export CC=$HOST-gcc 
$ export CXX=$HOST-g++ 
$ export AR=$HOST-ar 
$ export LD=$HOST-ld 
$ export AS=$HOST-as 
$ export NM=$HOST-nm 
$ export STRIP=$HOST-strip 
$ export RANLIB=$HOST-ranlib 
$ export OBJDUMP=$HOST-objdump 
$ export CPPFLAGS="--sysroot=$NDK_TOOLCHAIN/sysroot -I$NDK_TOOLCHAIN/sysroot/usr/include -I$NDK_TOOLCHAIN/include" 
$ export LDFLAGS="-L$NDK_TOOLCHAIN/sysroot/usr/lib -L$NDK_TOOLCHAIN/lib" 

然後我試圖交叉編譯的FreeType:

$ ./configure --with-sysroot=/cygdrive/d/Development/Android/ndk-standalone-15/sysroot --host=$HOST --prefix=/ft2tmp --build=$BUILD --without-zlib --with-png=no 

但我得到了一個錯誤:

FreeType build system -- automatic system detection

The following settings are used:

platform unix compiler
arm-linux-androideabi-gcc configuration directory ./builds/unix configuration rules ./builds/unix/unix.mk

If this does not correspond to your system or settings please remove the file `config.mk' from this directory then read the INSTALL file for help.

Otherwise, simply type make' again to build the library, or make refdoc' to build the API reference (the latter needs python).

cd builds/unix; /bin/sh ./configure '--with-sysroot=/cygdrive/d/Development/Android/ndk-standalone-15/sysroot' '--host=arm-linux-androideabi' '--prefix=/ft2tmp' '--build=' '--without-zlib' '--with-png=no' checking build system type... x86_64-unknown-cygwin checking host system type... arm-unknown-linux-androideabi checking for arm-linux-androideabi-gcc... arm-linux-androideabi-gcc checking whether the C compiler works... no configure: error: in /cygdrive/d/Development/tmp/freetype2/builds/unix': configure: error: C compiler cannot create executables See config.log' for more details builds/unix/detect.mk:86: recipe for target 'setup' failed make: * [setup] Error 77

一些config.log文件:

gcc version 4.8 (GCC) configure:2925: $? = 0 configure:2914: arm-linux-androideabi-gcc -V >&5 arm-linux-androideabi-gcc.exe: error: unrecognized command line option '-V' arm-linux-androideabi-gcc.exe: fatal error: no input files compilation terminated. configure:2925: $? = 1 configure:2914: arm-linux-androideabi-gcc -qversion >&5 arm-linux-androideabi-gcc.exe: error: unrecognized command line option '-qversion' arm-linux-androideabi-gcc.exe: fatal error: no input files compilation terminated. configure:2925: $? = 1 configure:2945: checking whether the C compiler works configure:2967: arm-linux-androideabi-gcc --sysroot=/cygdrive/d/Development/Android/ndk-standalone-15//sysroot -I/cygdrive/d/Development/Android/ndk-standalone-15//sysroot/usr/include -I/cygdrive/d/Development/Android/ndk-standalone-15//include -L/cygdrive/d/Development/Android/ndk-standalone-15//sysroot/usr/lib -L/cygdrive/d/Development/Android/ndk-standalone-15//lib conftest.c >&5 d:/development/android/ndk-standalone-15/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld.exe: error: cannot open crtbegin_dynamic.o: No such file or directory d:/development/android/ndk-standalone-15/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld.exe: error: cannot open crtend_android.o: No such file or directory d:/development/android/ndk-standalone-15/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld.exe: error: cannot find -lc d:/development/android/ndk-standalone-15/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld.exe: error: cannot find -ldl collect2.exe: error: ld returned 1 exit status configure:2971: $? = 1 configure:3009: result: no configure: failed

所以我的問題是我該如何正確地做到這一點?

編輯:

我以前未設置上CPPFLAGS和LDFLAGS和使用的./configure用--with-SYSROOT標誌,而現在它做得很好。 接下來的問題是,當我使用

make 

我得到以下錯誤:

$ make ./builds/unix/libtool --mode=compile arm-linux-androideabi-gcc -pedantic -ansi -I/cygdrive/d/Development/tmp/freetype2/objs -I./builds/unix -I/cygdrive/d/Development/tmp/freetype2/include -c -Wall -g -O2 -DFT_CONFIG_OPTION_SYSTEM_ZLIB -DFT_CONFIG_CONFIG_H="" -DFT2_BUILD_LIBRARY -DFT_CONFIG_MODULES_H="" -o /cygdrive/d/Development/tmp/freetype2/objs/ftsystem.lo /cygdrive/d/Development/tmp/freetype2/src/base/ftsystem.c libtool: compile: arm-linux-androideabi-gcc -pedantic -ansi -I/cygdrive/d/Development/tmp/freetype2/objs -I./builds/unix -I/cygdrive/d/Development/tmp/freetype2/include -c -Wall -g -O2 -DFT_CONFIG_OPTION_SYSTEM_ZLIB "-DFT_CONFIG_CONFIG_H=" -DFT2_BUILD_LIBRARY "-DFT_CONFIG_MODULES_H=" /cygdrive/d/Development/tmp/freetype2/src/base/ftsystem.c -fPIC -DPIC -o /cygdrive/d/Development/tmp/freetype2/objs/.libs/ftsystem.o arm-linux-androideabi-gcc.exe: error: /cygdrive/d/Development/tmp/freetype2/src/base/ftsystem.c: No such file or directory arm-linux-androideabi-gcc.exe: fatal error: no input files compilation terminated. /cygdrive/d/Development/tmp/freetype2/builds/freetype.mk:207: recipe for target '/cygdrive/d/Development/tmp/freetype2/objs/ftsystem.lo' failed make: * [/cygdrive/d/Development/tmp/freetype2/objs/ftsystem.lo] Error 1

回答

6

您必須設置提供freetype2所在位置的Windows風格路徑。以下是如何在您的Windows環境路徑中包含您在Android中用於開發的庫和文件。你需要爲freetype2做同樣的事情。

您可能會發現有用的檢查這些引用:

正如你可能會注意到,大多數的最佳material可用開發Andro ID應用程序是在Linux上:

enter image description here

如果你對Android開發認認真真的,這將是值得考慮您的開發遷移到Linux平臺。

你也應該對OpenGL Getting Started一看,它提供對Linux時,Windows和MacOS上使用OpenGL如何工作的幾個教程。採取溫和的step by step方法可以提高OpenGL開發技能的成效。

+2

對不起,我遲到的反應!問題出在路徑上,我成功地在Linux上交叉編譯了它。感謝您的鏈接,我自己找到了一些鏈接,我也會檢查其他鏈接! – ngspkinga

1

NDK for Windows不依賴於Cygwin的,更糟的是:它不承認/cygdrive/...路徑。嘗試使用D:/Development/tmp/freetype2

3

當涉及到用C語言編寫的庫的交叉編譯時,我們需要NDK。但是,在Windows上編譯這種類型的庫非常困難,有時會卡住。我建議你在Linux上嘗試編譯。它肯定會被編譯

+0

感謝您的幫助!它真的在Linux上工作。 – ngspkinga

+0

我已經寫了答案! – ngspkinga

0

首先,準備一個獨立的NDK工具鏈。請參閱https://stackoverflow.com/a/24978903/192373。我使用了以下參數:

bash-3.1$ d:/dev/Android/ndk/build/tools/make-standalone-toolchain.sh --platform=android-14 --toolchain=arm-linux-androideabi-4.8 --system=windows-x86_64 --arch=armv7a 

接下來,請確保您有工作/usr/bin/gcc

bash-3.1$ ./configure --host=arm-linux-androideabi --prefix=d:/Dev/Android/standalone-toolchain-armv7a-android-17 --without-zlib --with-png=no 

最後,我跑make,我看到

Directory of d:\dev\freetype-2.5.3\objs\.libs 

27/07/2014 10:43   3,462,596 libfreetype.a 
27/07/2014 10:43    960 libfreetype.la 
27/07/2014 10:43    961 libfreetype.lai 
27/07/2014 10:43   2,320,272 libfreetype.so