【发布时间】:2015-04-21 09:07:27
【问题描述】:
首先,我只知道有关 makefile 的基础知识,而且我是 Android NDK 的新手。
我有 x64 Linux Mint 17.1 和 Android NDK r8e,我正在尝试构建 NetHack for Android。
如README所述,基本思路是用本地Android NDK路径修改makefile:
NDK = /path/to/android-ndk-r8d
SYSROOT=$(NDK)/platforms/android-9/arch-arm
CC = $(NDK)/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc --sysroot=$(SYSROOT)
但我不断收到此错误:
cc -m32 -o makedefs makedefs.o ./monst.o ./objects.o /usr/bin/ld:搜索-lgcc时跳过不兼容的/usr/lib/gcc/x86_64-linux-gnu/4.8/libgcc.a
显然 /usr/bin/ld 被用来代替 arm-linux-androideabi-ld 并且它不寻找 libgcc.a 在 Android NDK 文件夹中。 我是否缺少一些环境变量或提出论点?
谢谢。
UPD1
这是完整的输出:
touch ../src/config.h-t
/opt/android/ndk/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc --sysroot=/opt/android/ndk/android-ndk-r8e/platforms/android-9/arch-arm -DANDROID -Wno-format -fsigned-char -I../include -c monst.c
/opt/android/ndk/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc --sysroot=/opt/android/ndk/android-ndk-r8e/platforms/android-9/arch-arm -DANDROID -Wno-format -fsigned-char -I../include -c objects.c
make[2]: Entering directory `/home/rzhilich/Projects/NetHack-Android/util'
cc -m32 -Wno-format -I../include -c -o makedefs.o makedefs.c
makedefs.c: In function ‘do_rumors’:
makedefs.c:361:2: warning: format not a string literal and no format arguments [-Wformat-security]
Fprintf(ofp,Dont_Edit_Data);
^
makedefs.c: In function ‘do_date’:
makedefs.c:560:2: warning: format not a string literal and no format arguments [-Wformat-security]
Fprintf(ofp,Dont_Edit_Code);
^
makedefs.c: In function ‘do_dungeon’:
makedefs.c:1232:2: warning: format not a string literal and no format arguments [-Wformat-security]
Fprintf(ofp,Dont_Edit_Data);
^
makedefs.c: In function ‘do_monstr’:
makedefs.c:1354:5: warning: format not a string literal and no format arguments [-Wformat-security]
Fprintf(ofp,Dont_Edit_Code);
^
makedefs.c: In function ‘do_permonst’:
makedefs.c:1395:2: warning: format not a string literal and no format arguments [-Wformat-security]
Fprintf(ofp,Dont_Edit_Code);
^
makedefs.c: In function ‘do_objs’:
makedefs.c:1711:2: warning: format not a string literal and no format arguments [-Wformat-security]
Fprintf(ofp,Dont_Edit_Code);
^
makedefs.c: In function ‘do_vision’:
makedefs.c:1866:5: warning: format not a string literal and no format arguments [-Wformat-security]
Fprintf(ofp,Dont_Edit_Code);
^
makedefs.c:1891:5: warning: format not a string literal and no format arguments [-Wformat-security]
Fprintf(ofp,Dont_Edit_Code);
^
cc -m32 -Wno-format -I../include -c ../src/monst.c -o monst.o
cc -m32 -Wno-format -I../include -c ../src/objects.c -o objects.o
cc -m32 -o makedefs makedefs.o ./monst.o ./objects.o
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.8/libgcc.a when searching for -lgcc
/usr/bin/ld: cannot find -lgcc
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.8/libgcc_s.so when searching for -lgcc_s
/usr/bin/ld: cannot find -lgcc_s
collect2: error: ld returned 1 exit status
make[2]: *** [makedefs] Error 1
make[2]: Leaving directory `/home/rzhilich/Projects/NetHack-Android/util'
make[1]: *** [../util/makedefs] Error 2
make[1]: Leaving directory `/home/rzhilich/Projects/NetHack-Android/src'
make: *** [nethack] Error 2
UPD2
显然安装说明不完整。出于某种原因,util 文件夹不是使用 Android NDK gcc 构建的,而是使用系统默认的 cc 构建的。安装以下软件包后:
- gcc-4.6
- gcc-4.6-multilib
- gcc-arm-linux-androideabi
我已使用update-alternatives 将系统默认 gcc 版本设置为 4.6。它解决了我的问题。
【问题讨论】:
-
能否请您添加生成该错误的完整规则?我知道是什么给你带来了麻烦......
-
嗯,抱歉,我虽然是你编写的makefile。我看了自述文件。您确定您正在编辑正确的文件 (
Makefile.src) 吗?这似乎是一个复杂的构建过程,其中使用不同的文件来生成“最终”makefile。 -
我猜你的意思是makefile中的“安装”规则?这是链接github.com/gurrhack/NetHack-Android/blob/master/sys/android/…
-
是的,我很确定我正在修改正确的 make 文件。
标签: linux gcc android-ndk makefile