【发布时间】:2011-06-16 10:03:21
【问题描述】:
我在 gcc 文档中读到它支持使用 -mandroid 和 -mbionic 开关构建 android 二进制文件。首先,我尝试使用从 svn 构建的本机 gcc。结果:
dancsi@dancsi-VirtualBox:~$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/i686-pc-linux-gnu/4.7.0/lto-wrapper
Target: i686-pc-linux-gnu
Configured with: ../source/configure --enable-threads --disable-nls
Thread model: posix
gcc version 4.7.0 20110611 (experimental) (GCC)
dancsi@dancsi-VirtualBox:~$ g++ test.cpp -mandroid -o test.out
dancsi@dancsi-VirtualBox:~$ file test.out
test.out: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.15, not stripped
基本上,它失败了。接下来,我尝试使用 target=arm-linux-androideabi 编译相同的 gcc 源代码(没有定义 sysroot,...),它通过了配置,但未能构建说 pthread.h 未找到:
In file included from ../.././gcc/gthr-default.h:1:0,
from ../../../combined/libgcc/../gcc/gthr.h:160,
from ../../../combined/libgcc/../gcc/unwind-dw2.c:37:
../../../combined/libgcc/../gcc/gthr-posix.h:41:21: fatal error: pthread.h: No such file or directory
compilation terminated.
那么,有人知道如何使用 gcc 构建 android 二进制文件(我不想使用代码源或 android-ndk)吗?
编辑: 我的配置选项
configure --target=arm-linux-android --host=i686-pc-linux-gnu --build=i686-pc-linux-gnu --disable-libssp --disable-libgomp --disable-nls --enable-languages=c,c++,java
【问题讨论】:
标签: android gcc android-ndk