[Android] NDK r7 includes 64-bit awk in standard release
小弟我第一次抓到 Google 的東西有問題,真是非常的感動 (?
其實這也不見得是錯誤,說不定是 Google 故意要把 64-bits 東西當做主流 @@
但我的機器就是只有32而已,你硬給我64是怎樣 = =
這問題簡單的說,就是 NDK r7 裡面的 awk 執行檔是 64 bits 所使用的,所以在一般的 32 bits 機器上會完全無法使用,必須要把它換掉才行,大概的錯誤訊息如下…….
1
2
3
4
5
6
7
8
9
|
deren@ubuntu1104:
/opt/android-ndk-r7/samples/hello-jni/jni
$ ndk-build
/opt/android-ndk-r7/prebuilt/linux-x86/bin/awk
: 1:ELF: not found
/opt/android-ndk-r7/prebuilt/linux-x86/bin/awk
: 4: Syntax error: word unexpected (expecting
")"
)
Android NDK: Host
'awk'
tool is outdated. Please define HOST_AWK to point to Gawk or Nawk !
/opt/android-ndk-r7/build/core/init
.mk:258: *** Android NDK: Aborting. . Stop.
|
到這個 awk 所在的檔案夾裡面去,我們檢查一下是不是檔案有問題……
1
2
3
4
|
deren@ubuntu1104:
/opt/android-ndk-r7/prebuilt/linux-x86/bin
$
file
*
awk
: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs),
for
GNU
/Linux
2.6.15, stripped
make
: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs),
for
GNU
/Linux
2.6.8, stripped
sed
: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs),
for
GNU
/Linux
2.6.8, stripped
|
看吧看吧 = = ,這個 awk 居然是 64 位元的版本………我們來給他修正一下!
1
2
3
4
|
deren@ubuntu1104:
/opt/android-ndk-r7/prebuilt/linux-x86/bin
$
mv awk awk -x64
deren@ubuntu1104:
/opt/android-ndk-r7/prebuilt/linux-x86/bin
$
echo
`
type
awk
`
awk
is
/usr/bin/awk
deren@ubuntu1104:
/opt/android-ndk-r7/prebuilt/linux-x86/bin
$
ln -s /usr/bin/awk awk
|
這樣應該就沒問題了,讓我們回到原來的地方編譯程式……….
1
2
3
4
5
6
|
deren@ubuntu1104:
/opt/android-ndk-r7/samples/hello-jni/jni
$ ndk-build
Gdbserver : [arm-linux-androideabi-4.4.3] libs
/armeabi/gdbserver
Gdbsetup : libs
/armeabi/gdb
.setup
Compile thumb : hello-jni <= hello-jni.c
SharedLibrary : libhello-jni.so
Install : libhello-jni.so => libs
/armeabi/libhello-jni
.so
|
大功告成,收工!