Sign in to follow this  
sjaakiejj

LuaBind: Linker Problems

Recommended Posts

Hi,

I set up my classes with Lua today, and tried to use luabind to expose functions and classes. However, when I try to compile it, I get the following error:

undefined reference to `luabind::open(lua_State*)'


I'm using Linux, and I can't find anything about compiler flags that have to be set - if any.

Thanks in advance for your help.

Share this post


Link to post
Share on other sites
Quote:
Original post by sjaakiejj
Hi,

I set up my classes with Lua today, and tried to use luabind to expose functions and classes. However, when I try to compile it, I get the following error:

undefined reference to `luabind::open(lua_State*)'


I'm using Linux, and I can't find anything about compiler flags that have to be set - if any.


That's a linker error, not a compiler error.

Are you passing the Luabind library to the linker?

Share this post


Link to post
Share on other sites
I added the static link path, pointing to the libluabind.a file, but that didn't make much of a difference. I read on another forum that you had to add -lluabind as a linker flag, so I did this, but received the error "Cannot find -lluabind" instead. I looked through Luabinds documentation but can't find anything about it.

Share this post


Link to post
Share on other sites
Quote:
Original post by sjaakiejj
I added the static link path, pointing to the libluabind.a file, but that didn't make much of a difference.

What does this mean? Did you change something in your IDE, or your makefile, or do something different on the command line?

Quote:
I read on another forum that you had to add -lluabind as a linker flag, so I did this, but received the error "Cannot find -lluabind" instead. I looked through Luabinds documentation but can't find anything about it.


Assuming you're using GCC, that you've built luabind as a static library at foo/bar/libluabind.a, and that you're invoking the linker via the g++ frontend, then you need to do make sure that the linker command issued is in one of the following forms:

g++ [...] -Lfoo/bar -lluabind [...]

or

g++ [...] -lfoo/bar/libluabind.a [...]

Also, it is important to note that by default, the order in which you specify the libraries on the GNU linker command line is significant. If library B depends on library A, then B should be placed before A on the command line. There are options to change this behaviour, but it is another common reason for undefined reference errors.

Share this post


Link to post
Share on other sites
Following on what you said, I tried it again and it still didn't compile, complaining about not being able to find the file I pointed at, or complaining that there were undefined references. I solved the problem though.

When I was looking at the .so files, I noticed an extra d behind libluabind, so the file was named libluabindd.so. This seemed a bit odd to me, but I decided to give it a go and it worked by compiling with the linker flag -lluabindd, even though the actual .a file is called libluabind.a.

The thing is however that libluabindd.so is the debug version, which seems to be the only one available in the way luabind has been installed to my disk. Is there any change I have to make to the luabind install which will give me the actual release version?

Thanks for your help though.

EDIT:
Tried running the project, but I get another error:
error while loading shared libraries: libluabindd.so.0.9.0: cannot open shared object file: No such file or directory

Even though I have included the directory which has that exact file in it as a library directory.

[Edited by - sjaakiejj on December 6, 2010 6:57:34 AM]

Share this post


Link to post
Share on other sites
Quote:
Original post by sjaakiejj
The thing is however that libluabindd.so is the debug version, which seems to be the only one available in the way luabind has been installed to my disk. Is there any change I have to make to the luabind install which will give me the actual release version?


I cannot even begin to speculate without you first having described the mechanism by which you installed Luabind.

Which operating system are on using?
Are you using a package management system?
If not, how are you building LuaBind (and Lua)?

Share this post


Link to post
Share on other sites
I'm using Linux, and I built LuaBind using bjam from the command line, which I have to say is an awfully difficult way to build the libraries, but the only way described in the manual for LuaBind. Building went perfectly, with tests coming out without errors. The only problem, of course, is that Luabind is currently in Debug mode.

I managed to solve the problem of not being able to locate the file though.

Share this post


Link to post
Share on other sites
Quote:
Original post by sjaakiejj
I'm using Linux, and I built LuaBind using bjam from the command line, which I have to say is an awfully difficult way to build the libraries, but the only way described in the manual for LuaBind. Building went perfectly, with tests coming out without errors. The only problem, of course, is that Luabind is currently in Debug mode.

I managed to solve the problem of not being able to locate the file though.


I have to say that I also find bjam hard to use. I have built LuaBind manually with success. It took no more than adding the C++ source files to a makefile. Presumably you could do the same with whatever project/build mechanism you prefer.

Share this post


Link to post
Share on other sites
i had the same issue and all I did was
blueskin@zion:~/lib/luabind-0.9.1/bin/gcc-4.4.3/release$ ln -s libluabind.so.0.9.0 libluabind.so
created a new symbolic link and it works. I sometimes get the error and I realize later that this is what I should do.

Share this post


Link to post
Share on other sites
i had the same issue and all I did was

blueskin@zion:~/lib/luabind-0.9.1/bin/gcc-4.4.3/release$ ln -s libluabind.so.0.9.0 libluabind.so

created a new symbolic link and it works. I sometimes get the error and I realize later that this is what I should do.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this