Sign in to follow this  

Stupid LUA problem

Recommended Posts

I am attempting to embed LUA into a simple console application. I downloaded the compiled library and dlls from this website: I then used the code from the article here on gamedev:
#include <stdio.h>
extern "C"
 #include <lua.h>
 #include <lualib.h>
int main(int argc, char* argv[ ])
   lua_State* luaVM = lua_open(0);
   if (NULL == luaVM)
      printf("Error Initializing lua\n");
      return -1;
   // initialize lua standard library functions


   // Do stuff with lua code.
   char* strLuaInput = "a = 1 + 1;\nprint( a);\n";
   lua_dostring(luaVM, strLuaInput);
   while(1) {}
   return 0;
However the program crashes on the first line (the lua_open call)... any ideas?

Share this post

Link to post
Share on other sites
Also, before you run into the error on your own, lua_*libopen leave things on the stack. It's usually wise to call lua_settop(L, 0) after calling them.

Share this post

Link to post
Share on other sites

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