操作系统:Linux Ubuntu
编译器:gcc
Launguage:C ++
2个项目:
项目1:使用Lua构建动态库; (libBattleCore.so)
项目2:使用Project 1生成的libBattleCore.so构建控制台应用程序
Project 2编译命令:
g++ -Wall -fexceptions -O2 -o bin/Release/BattleConsole libBattleCore.h main.cpp -I/home/Downloads/lua-5.2.3/install/include/ -L. -lBattleCore
错误消息
./libBattleCore.so: undefined reference to `luaopen_table'
./libBattleCore.so: undefined reference to `lua_getfield'
./libBattleCore.so: undefined reference to `lua_isstring'
...
./libBattleCore.so: undefined reference to `lua_tolstring'
collect2: error: ld returned 1 exit status
问题是什么以及解决方案是什么?感谢
Project 1构建命令:
g++ -O2 -fPIC -shared -o bin/Release/libBattleCore.so -I/home/Downloads/lua-5.2.3/install/include/ -L/home/Downloads/lua-5.2.3/install/lib/ -llua Basic_Battle/Arsenal.cpp Basic_Battle/BaseEntity.cpp ...(lots of cpp files)
ldd libBattleCore.so:
linux-vdso.so.1 => (0x00007ffff7ffe000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f008f35a000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f008f054000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f008ee3d000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f008ea77000)
/lib64/ld-linux-x86-64.so.2 (0x00007f00946a8000)
答案 0 :(得分:0)
问题解决了......
仍然用lua ...
编译项目2编译命令:
g++ -Wall -fexceptions -O2 -o bin/Release/BattleConsole libBattleCore.h main.cpp -L. -lBattleCore -llua -ldl
动态lib(.so)应该复制到/ usr / lib / 然后ldd BattleCosnole将列出libBattleCore.so => / usr / ... not" not found"再次
我仍然想要一些其他方法来自定义.so
的路线由于