binding lua (newbie)

R

Roman Fordinal

please, what's wrong? :(

#include <stdio.h>
extern "C"
{
#include <lua.h>
#include <lualib.h>
}

int main()
{
lua_State *L = lua_open(); /* opens Lua */
// lua_baselibopen(L);
// lua_iolibopen(L);
lua_close(L);
}


g++ -Wall message.cc -o message
/tmp/ccWx0Gia.o(.text+0x11): In function `main':
: undefined reference to `lua_open'
/tmp/ccWx0Gia.o(.text+0x1f): In function `main':
: undefined reference to `lua_close'
collect2: ld returned 1 exit status
 
J

John Harrison

Roman Fordinal said:
please, what's wrong? :(

#include <stdio.h>
extern "C"
{
#include <lua.h>
#include <lualib.h>
}

int main()
{
lua_State *L = lua_open(); /* opens Lua */
// lua_baselibopen(L);
// lua_iolibopen(L);
lua_close(L);
}


g++ -Wall message.cc -o message
/tmp/ccWx0Gia.o(.text+0x11): In function `main':
: undefined reference to `lua_open'
/tmp/ccWx0Gia.o(.text+0x1f): In function `main':
: undefined reference to `lua_close'
collect2: ld returned 1 exit status

You haven't included the relevant library in your linking stage. This isn't
a C++ language issue, it's a 'how do I operate my compiler issue', -Llua
might do the trick, but if not then consult your compiler documentation.

john
 
R

Roman Fordinal

John said:
You haven't included the relevant library in your linking stage. This
isn't a C++ language issue, it's a 'how do I operate my compiler issue',
-Llua might do the trick, but if not then consult your compiler
documentation.
oh yes! thanx :)

g++ -llua ... :)
 
?

=?ISO-8859-1?Q?=22Nils_O=2E_Sel=E5sdal=22?=

Roman said:
please, what's wrong? :( ...
g++ -Wall message.cc -o message
/tmp/ccWx0Gia.o(.text+0x11): In function `main':
: undefined reference to `lua_open'
/tmp/ccWx0Gia.o(.text+0x1f): In function `main':
: undefined reference to `lua_close'
collect2: ld returned 1 exit status
Link with lua.
g++ -Wall message.cc -o message -llua
This is btw a lua question/gcc question not a C++ question
 
N

Nick

Roman Fordinal said:
please, what's wrong? :(

#include <stdio.h>
extern "C"
{
#include <lua.h>
#include <lualib.h>
}

My advice would be to advance from "self-proclaimed newbie" to "got the hang
of compiling C++ projects" before trying to tackle something as advanced as
binding in a scripting language. I'm not trying to be insulting, I'm just
saying it's a good idea to get the hang of the basic stuff or else things
like this will be really difficult.

You should also look at one of the many code wrappers that people have made
to facilitate binding Lua to C/C++. Luabind is quite popular.
http://lua-users.org/wiki/LuaAddons
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top