工作上偶爾要編一些外部的 library
不同版本的 ndk 的 toolchains 通常只有一些改變而已
除了 r4 -> r5 路徑變比較大(更早的我沒用過QQ)
要維護 library configuration script 大多在搞定路徑。
先前有些專案都很『樸拙』地手工找出路徑,再 hardcode 上去,
趁失眠來做些整理的工作,寫個簡單的 script 產生路徑:
https://gist.github.com/3092282#file_my_ndk_tool.py
例如:產生 mips 用的相關路徑:
main("/Users/qrtt1/app/NDKs/android-ndk-r8", "mips", "android-9")
輸出:
MY_NDK_LIB=/Users/qrtt1/app/NDKs/..../android-9/arch-mips/usr/lib
MY_NDK_INCLUDE=/Users/qrtt1/app/NDKs/..../android-9/arch-mips/usr/include
MY_NDK_CC_PREFIX=/Users/qrtt1/app/NDKs/..../bin/mipsel-linux-android-
MY_NDK_CC=/Users/qrtt1/app/NDKs/..../bin/mipsel-linux-android-gcc
MY_NDK_LIBGCC=/Users/qrtt1/app/NDKs/..../lib/gcc/mipsel-linux-android/4.4.3/libgcc.a
有了這些變數,剩下來的工作就是填入 configuration 參數,
以 libmp3lame 為例,簡單地將變數填上,
該給的參數都給(這不是廢話>"< 看 error message 缺什麼,就給什麼唄xd)
https://gist.github.com/3092282#file_cfg_libmp3lame.sh
最後看一下結果,嗯。有出現 mips32
qty:lame-3.99.5 qrtt1$ file libmp3lame.so
libmp3lame.so: ELF 32-bit LSB shared object, MIPS, \
MIPS32 version 1 (SYSV), dynamically linked, \
with unknown capability 0xf41 = 0x756e6700, not stripped
(至少看結果是對的,但能不能跑是另一個問題了 :P)
因為目前 team 裡只有自己在弄 NDK 的東西,
也許做法很土炮,如果版友有新的方法也能分享一下呦。
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 114.43.123.20
※ 編輯: qrtt1 來自: 114.43.123.20 (07/12 03:38)