• Popular Now

• 12
• 12
• 9
• 10
• 13

This topic is 2653 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

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.

Share on other sites
Quote:
 Original post by sjaakiejjHi,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 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 on other sites
Quote:
 Original post by sjaakiejjI 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:

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 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?

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 on other sites
Quote:
 Original post by sjaakiejjThe 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 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 on other sites
Quote:
 Original post by sjaakiejjI'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 on other sites
I'll give that a try then.

Thanks for all your help :)