build libusb for Android
平臺(tái)
libusb版本:libusb-1.0.20
Ubuntu: 14.04
NDK:android-ndk-r9d
測(cè)試手機(jī):三星S4
開發(fā)板:GD32
==================
?
Building:
---------
?
To build libusb for Android do the following:
?
1. Download the latest NDK from:
http://developer.android.com/tools/sdk/ndk/index.html
?
2. Extract the NDK.
?
3. Open a shell and make sure there exist an NDK global variable
set to the directory where you extracted the NDK.
?
4. Change directory to libusb's "android/jni"
?
5. Run "ndk-build".(需要設(shè)置環(huán)境變量或者使用絕對(duì)路徑)
?
The libusb library, examples and tests can then be found in:
"android/libs/$ARCH"
?
Where $ARCH is one of:
armeabi(測(cè)試使用此架構(gòu),armeabi-v7a未測(cè)試)
armeabi-v7a
x86
?
Installing:
-----------
For a rooted device it is possible to install libusb into the system
image of a running device:
?
1. Connect the device to a machine running ADB.
?
2. Execute the following commands on the machine
running ADB:
?
# Make the system partition writable
adb shell su -c "mount -o remount,rw /system"
?
# Install libusb
adb push obj/local/armeabi/libusb1.0.so /sdcard/
adb shell su -c "cat > /system/lib/libusb1.0.so < /sdcard/libusb1.0.so"
adb shell rm /sdcard/libusb1.0.so
?
?
Test:
-----------
1. new project file
1) 任意目錄下mkdir libusb_for_android
2) 在libusb_for_android/ 添加libusb1.0.so、libusb.h、usbtest2.0.c,并且新建jni目錄
3) 在jni/ 新建Android.mk和Application.mk
?
2. 在jni/下運(yùn)行:/opt/android_ndk/android-ndk-r9d/ndk-build
在libusb_for_android/libs/armeabi/下即可找到產(chǎn)生的可執(zhí)行文件usbtest
?
3. 將usbtest adb push到手機(jī)的sdcard/
?
4. 將開發(fā)板和手機(jī)相連,然后再手機(jī)的超級(jí)終端下運(yùn)行:./usbtest
?
總結(jié)
以上是生活随笔為你收集整理的build libusb for Android的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 亡灵战神赛恩S7天赋加点图 赛恩S7出装
- 下一篇: USB共享网络:android手机通过U