2015-09-18 14 views
-1

當我編譯libb.so它取決於liba.so。我可以運行如何在可執行文件中使用函數時編譯.so。

g++ -la. 

libb.so使用的函數從可執行c,什麼是正確的命令?

g++ -lc 

拋出錯誤!

我想在android下編譯weston。 gl_render.so使用weston的函數。

+0

請編輯您的帖子與您的問題的深入信息。嘗試儘可能描述。這樣,你會得到更好的答案。 – Mariano

回答

0

我想編譯'libapi_simple.so',它使用名爲'test'的可執行文件的函數int module_add(int,int)。 objs編譯和finnally cmd如下:

/code/phone/xmake/prebuilts/gcc/linux-x86/arm/arm-linux-gnueabi-4.9-glibc-2.20/bin/arm-linux- gnueabi-g ++ -shared -Wl,-soname,libapi_simple.so -fPIC -fPIE -o /code/phone/out/platforms/phone.amlogic.eng.arm/target/obj/SHARED_LIBRARY/LINKED/libapi_simple.so/code /phone/out/platforms/phone.amlogic.eng.arm/target/obj/SHARED_LIBRARY/libapi_simple_intermediates/api.o /code/phone/out/platforms/phone.amlogic.eng.arm/target/obj/SHARED_LIBRARY/libapi_simple_intermediates /private.o \ -L/code/phone/out/platforms/phone.amlogic.eng.arm/target/obj/SHARED_LIBRARY/LINKED \ -L/code/phone/out/platforms/phone.amlogic.eng .arm/target/obj/STATIC_LIBRARY \ -Wl, - no-undefined -Wl, - build-id -L/code/phone/out/platforms/phone.amlogic.eng。 arm/target/obj/SHARED_LIBRARY/LINKED -L/code/phone/out/platforms/phone.amlogic.eng.arm/target/rootfs/lib -L ​​/ code/phone/out/platforms/phone.amlogic.eng。 arm/target/rootfs/usr/lib \ -Wl,-rpath =/usr/lib \ -Wl,-rpath-link =/code/phone/out/platforms/phone.amlogic.eng.arm/target/OBJ/SHARED_LIBRARY /聯:/code/phone/out/platforms/phone.amlogic.eng.arm/target/rootfs/lib:/code/phone/out/platforms/phone.amlogic.eng.arm/target/rootfs/ usr/lib /code/phone/out/platforms/phone.amlogic.eng.arm/target/obj/SHARED_LIBRARY/libapi_simple_intermediates/api.o:In function get_api_tag()': /code/phone/xmake/example/SHARED_LIBRARY_SIMPLE/api.cpp:9: undefined reference to module_add(int,int)' collect2:error:ld returned 1退出狀態 make:*** [/code/phone/out/platforms/phone.amlogic.eng.arm/target/obj/SHARED_LIBRARY/LINKED/libapi_simple.so]錯誤1

謝謝

+0

我想知道如何在上面的cmd中添加'test'來獲得正確的結果。如果'測試'是.so。問題很簡單。但它是一個可執行的項目。當我從上面刪除'-Wl, - no-undefined'時,編譯成功但運行失敗 –

相關問題