Undefined reference error when using Lua API
I wrote a small test program, and this is what happens when I try to compile it:
Code:
$ g++ -llua main.cpp |
Arch, 64bits : ls /usr/lib/liblua*
/usr/lib/liblua.a /usr/lib/liblua.so@ /usr/lib/liblua.so.5.1* The objects luaL_newstate luaL_openlibs lua_close are present : readelf -s /usr/lib/liblua.so | grep luaL_newstate 134: 00000000000194f0 43 FUNC GLOBAL DEFAULT 11 luaL_newstate 554: 00000000000194f0 43 FUNC GLOBAL DEFAULT 11 luaL_newstate etc. etc. Are you missing 'liblua.so.5.1' ? Or is it not an "ELF 64-bit LSB shared object, x86-64" ? ( The file command and 'ls -l /usr/lib/liblua.so' will show, if it is a valid link.) .. |
Code:
$ ls -l /usr/lib/liblua* |
Quote:
Markus |
777 for <lib>.so links :
Never thought about it. Seems to be the same for other libraries too. |
You need to place the lib after the .cpp file so it gets searched after the linker knows what dependencies the .cpp has.
Kevin Barry |
Quote:
Code:
g++ main.cpp -llua |
Quote:
Try wrapping the #include with extern "C" { } in case g++ is mangling the library symbols from the header. Kevin Barry |
Quote:
I'm marking the thread as solved. |
All times are GMT -5. The time now is 04:14 AM. |