ndk串連第三方庫

來源:互聯網
上載者:User

看ndk說明文檔關於第三方庫(Prebuilts)的用法,安裝上面的方法試了下,結果老是串連不上,第三方庫中的函數串連不到:

Administrator@4ec48ba026e34ae /cygdrive/e/myprj/hello-jni/jni
$ /cygdrive/e/work/android-ndk-r5b/ndk-build
Compile thumb  : hello-jni <= hello-jni.c
SharedLibrary  : libhello-jni.so
E:/myprj/hello-jni/obj/local/armeabi/objs/hello-jni/hello-jni.o: In function `
st1':
E:/myprj/hello-jni/jni/hello-jni.c:12: undefined reference to `InitWordInfo'
E:/myprj/hello-jni/jni/hello-jni.c:21: undefined reference to `debug_printf'
E:/myprj/hello-jni/jni/hello-jni.c:24: undefined reference to `debug_printf'
E:/myprj/hello-jni/jni/hello-jni.c:43: undefined reference to `debug_printf'
E:/myprj/hello-jni/jni/hello-jni.c:62: undefined reference to `debug_printf'
E:/myprj/hello-jni/jni/hello-jni.c:16: undefined reference to `debug_printf'
E:/myprj/hello-jni/obj/local/armeabi/objs/hello-jni/hello-jni.o:E:/myprj/hello
ni/jni/hello-jni.c:78: more undefined references to `debug_printf' follow
collect2: ld returned 1 exit status
make: *** [/cygdrive/e/myprj/hello-jni/obj/local/armeabi/libhello-jni.so] Erro
1


後來在網上查到原因,原來是可惡Prebuilts文檔有錯誤

http://hi.baidu.com/nalch/blog/item/f6a1ed6aec69d2cd80cb4a59.html

LOCAL_SHARED_LIBRARIES和LOCAL_SHARED_LIBRARY:注意前者是複數S形式,用於Link多個庫(只有一個也可以用),後者只能添加一個連結庫,可惡的文檔關於Prebuilts的介紹裡面給出的例子是LOCAL_SHARED_LIBRARY,使用兩個庫的時候第二個庫死也link不上。


Android.mk修改後,就可以串連通過了。

LOCAL_PATH := $(call my-dir)include $(CLEAR_VARS)LOCAL_MODULE := my-initLOCAL_SRC_FILES := libinit.so#LOCAL_SRC_FILES := ../../sojni/libs/armeabi/libinit.soinclude $(PREBUILT_SHARED_LIBRARY)include $(CLEAR_VARS)LOCAL_MODULE := hello-jni#LOCAL_SHARED_LIBRARY := my-init    #應該用複數形式,否則串連不上第三方庫中的函數LOCAL_SHARED_LIBRARIES := my-initLOCAL_SRC_FILES := hello-jni.cinclude $(BUILD_SHARED_LIBRARY)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.