当我编译libb.so
时,它取决于liba.so
。我可以跑
g++ -la.
当libb.so
使用可执行文件c
中的函数时,正确的命令是什么?
g++ -lc
抛出错误!!
我正在尝试在android下编译weston。 gl_render.so
使用weston的函数。
答案 0 :(得分:0)
我想编译'libapi_simple.so'并使用名为'test'的可执行文件的int module_add(int,int)函数。 objs被编译并且最终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链路= /代码/电话输入/输出/平台/ phone.amlogic.eng.arm /目标/ OBJ / SHARED_LIBRARY / LINKED:/code/phone/out/platforms/phone.amlogic.eng.arm/目标/根文件系统/ 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:在函数get_api_tag()':
/code/phone/xmake/example/SHARED_LIBRARY_SIMPLE/api.cpp:9: undefined reference to
module_add(int,int)'中
collect2:错误:ld返回1退出状态
make:*** [/code/phone/out/platforms/phone.amlogic.eng.arm/target/obj/SHARED_LIBRARY/LINKED/libapi_simple.so]错误1
感谢