After a bit of a struggle, I've gotten Lua to work with Visual Studio 2012 (Lua 5.2). Unfortunately, now, when I run some simple test code, it crashes at runtime with an unhandled exception, but only when I call lua_close(). Here's the code:

Attached Thumbnails

Good old "Access Violation Error": Trying to access something that's out of the page or do something that a page isn't authorized for. Sometimes it can be trying to free a pointer that's not allocated. Possibly Lua is being de-initialized and then trying to free an internal pointer or something. If you've got everything set up right then it may actually be a Lua code problem. I had a similar problem with IrrKlang a while back and they fixed it in the next release (after I spent 5 hours trying to find the problem).

Check the Lua site and see if there's a newer version or else maybe a ticket in the bug-tracker.

Apart from that I think we'd need to know more about what's going on at your end. Does the Lua embedding doc say anything about necessary compiler or linker settings? Do you really need to extern "C" an .hPP file? What is the returned value from dostring()?

Poking around a little on google, do you need to call "luaL_openlibs(L)" after creating the state?

Edited by Khatharr, 03 November 2012 - 05:22 AM.

void hurrrrrrrr() {__asm sub [ebp+4],5;}

There are ten kinds of people in this world: those who understand binary and those who don't.