Sign in to follow this  

Problem using Lua API

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I'm trying to use Lua 5 with C++, but it just won't work. I originally compiled my own libraries, then found some pre-compiled libraries on the web, but I always get a linker error. Specifically with lua_dofile() and lua_dostring(). The project is linked to Lua+Lib.lib, and I've used the extern "C" for the includes. Any ideas?

Share this post


Link to post
Share on other sites
Those functions are defined in the auxiliary library (lauxlib.h), but are deprecated and might not be available in your distribution. I'd suggest you try the luaL_loadfile function instead. Example:


luaL_loadfile (L, "script.lua");
if (lua_isfunction (L, -1))
{
lua_pcall (L, 0, 0, 0);
}
else
{
std::cout << "error: script.lua not found!" << std::endl;
}



Share this post


Link to post
Share on other sites

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

If you intended to correct an error in the post then please contact us.

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