• 13
• 15
• 19
• 27
• 9

# Problem with lua and C++

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

## Recommended Posts

Ive been trying to get lua and C++ to work together for a few days now. I have had a little bit of success but I'm having what I'm pretty sure is some linking issues.
I've followed a few tutorials, but none in my particular IDE or on my OS.
I can open the interpreter fine.. I have issues when I try to actually use the interpreter. Errors like this..

/home/cody/luatest.cpp|12|error: ‘lua_openlibs’ was not declared in this scope|

here is my code::

extern "C" { #include "lua5.1/lua.h" #include "lua5.1/lauxlib.h" #include "lua5.1/lualib.h" } #include <stdio.h> int main(int argc, char* argv[ ]) { lua_State* lua = lua_open(); lua_openlibs(lua); return 0; }

I'm only linking lua5.1 which is probably part of the problem. I could possibly be missing a header file also.
Thanks guys

##### Share on other sites
openlibs is part of the the auxiliary library. All functions in the aux library is prefixed with luaL_, so the function you are looking for is "[font=monospace]

## luaL_openlibs[/font]". The Lua reference manual is a great source for checking whether a function has lua_ or luaL_ prefix, which parameters it takes and so on.

##### Share on other sites
Ahhhhh.. perhaps I shouldnt be watching low resolution tutorials on youtube XD. Thanks. and I looked at the lua documentation. should have looked at the reference. my mistake

##### Share on other sites
Something I see from Lua tutorials which you have copied is the use of 'lua_open', it has been depreciated for some time and IIRC removed from 5.2

##### Share on other sites
Okay, but it isnt depreciated in lua 5.1 correct? (the version i have)

##### Share on other sites

Okay, but it isnt depreciated in lua 5.1 correct? (the version i have)

lua_open is a 5.0 function that was depreciated in 5.1 for luaL_newstate and lua_newstate, again IIRC lua_open is just a define for lua_newstate in 5.1.

##### Share on other sites

[quote name='Coder4Life95' timestamp='1304294632' post='4805210']
Okay, but it isnt depreciated in lua 5.1 correct? (the version i have)

lua_open is a 5.0 function that was depreciated in 5.1 for luaL_newstate and lua_newstate, again IIRC lua_open is just a define for lua_newstate in 5.1.
[/quote]

this is why i need to stop being lazy watching tutorials and read documentation thoroughly. correct?