I''m just trying to add Lua scripting support to one of my programs running on Mandrake Linux 9.0, and am having a few problems.
I altered the makefile so that the final gcc command looks like this:
gcc -lcrypt -o progname lua/lib/liblua.a lua/lib/liblualib.a first.o second.o (...etc etc...)
Now, those .a files definitely exist, and they definitely contain numerous Lua-related .o files as I would expect. But it just gives me several linkage errors such as "undefined reference to `lua_gettop''" or "undefined reference to `lua_open''". I don''t understand why the reference is undefined as I have the libraries right there in the linking command, deliberately placed first to take effect before any of the other object files are linked. I''m using gcc rather than g++ so the name mangling thing that catches so many Lua users out shouldn''t be the issue here. (gcc chokes on the extern "C" fix anyway, which I assume proves it''s running in C and not C++ mode.) I know it''s finding the library files as it gives an error if I put in an imaginary filename there.
So, I''m at a loss to see why it isn''t managing to link these files in. Do I need something else besides the .a files?
This is also where the 2nd half of my question comes in; I''m assuming there must be a command to see what symbols are exported by a library. This would let me verify that the library does indeed provide the symbols that I''m looking for. Any ideas?
[ MSVC Fixes | STL Docs | SDL | Game AI | Sockets | C++ Faq Lite | Boost
Asking Questions | Organising code files | My stuff | Tiny XML | STLPort]
Problems linking Lua/seeing exported libary symbols
What version of Lua? In 5.0, they moved a bunch of the functions to luaauxlib.
SpiffGQ
Yeah, I''m using version 5, but lua_open wouldn''t be among those functions would it?
Incidentally I found the answer to my second question; the ''nm'' command seems to confirm that all the symbols I need are exported in the libraries I made. I just can''t manage to link with them.
quote:
Original post by Kylotan
Yeah, I''m using version 5, but lua_open wouldn''t be among those functions would it?
That is weird. Here is a make file that I use to compile a simple lua program that just executes a script. It uses gettop and open, but it is c++ (I don''t think that would be a problem, though).
CC=g++LUA_PREFIX=/usr/local/libSTATIC_LIBS=$(LUA_PREFIX)/liblua.a $(LUA_PREFIX)/liblualib.aconsole: console.cpp $(STATIC_LIBS) $(CC) console.cpp $(STATIC_LIBS) -o consoleclean: rm -rf *.o *~ ~* core console a.out
Does the output of nm show lua_gettop or lua_open? When I run nm console it shows both. I can''t really think of why its not linking.
SpiffGQ
I just remembered something: the linker program that gcc uses transparently needs dependencies listed first. Try moving first.o, second.o, etc to the front of the list.
SpiffGQ
nm definitely showed lua_open. (I didn''t look hard enough to see the other function but I''m pretty sure everything is in there.) And since dependencies need to be listed first, what would the point of moving them to the front be? They depend on the lua libs, not the other way around.
[ MSVC Fixes | STL Docs | SDL | Game AI | Sockets | C++ Faq Lite | Boost
Asking Questions | Organising code files | My stuff | Tiny XML | STLPort]
[ MSVC Fixes | STL Docs | SDL | Game AI | Sockets | C++ Faq Lite | Boost
Asking Questions | Organising code files | My stuff | Tiny XML | STLPort]
Sorry, that was a typo. I meant to say that the dependants need to be listed first. That is, if a.o depends on b.o, then you need to list
gcc a.o b.o
instead of
gcc b.o a.o
If a.o depends on b.o and b.o depends on a.o, you have to do this number:
gcc a.o b.o a.o
or
gcc b.o a.o b.o
Kind of quirky, but it ususally isn''t a problem.
gcc a.o b.o
instead of
gcc b.o a.o
If a.o depends on b.o and b.o depends on a.o, you have to do this number:
gcc a.o b.o a.o
or
gcc b.o a.o b.o
Kind of quirky, but it ususally isn''t a problem.
SpiffGQ
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement