Jump to content
  • Advertisement
Sign in to follow this  
cdmac

Problem using Lua API

This topic is 5054 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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!