我在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.mkIf 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:
config.log’ for more details
C compiler cannot create executables
See
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上使用了unset,并使用带有–with-sysroot标志的./configure,现在它正常运行.
接下来的问题是,当我使用时
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
解决方法
您可能会发现检查这些引用很有用:
> Android NDK Cross-Compile Setup (libpng and freetype)
> OpenGL Programming/Installation/Android NDK
> Setting up Native OpenGL ES* on Android* Platforms
> Calling OpenGL from C on Android,Using the NDK
您可能会观察到,开发Android应用程序的大部分最佳material都在Linux上:
如果您对Android开发非常认真,那么考虑将您的开发转移到Linux平台是值得的.
您还应该看一下OpenGL Getting Started,它提供了有关如何在Linux,Windows和MacOS上使用OpenGL的几个教程.采用温和的step by step方法可以更有效地成功提高您的OpenGL开发技能.