pkulchenko / wxlua

wxlua: Lua bindings for wxWidgets cross-platform GUI toolkit; supports Lua 5.1, 5.2, 5.3, 5.4, LuaJIT and wxWidgets 3.x
306 stars 59 forks source link

What libs to link against on windows #92

Closed Kristopher38 closed 3 years ago

Kristopher38 commented 3 years ago

I'm using Windows and compiling with msvc. I followed the install instructions and managed to build wxLua that way. I now want to use wxLua from the C++ side and I'm trying to create a wxLuaState, but I can't figure out which libs should I link against - the only combination that seemed to work was wxlua-wx31mswud-3.1.0.0.lib and lua.lib, but that throws some access violation exceptions in random places, usually in the Lua source, at runtime (although I should mention that I put wxLua-build\bin\Debug into the PATH env variable as it was complaining that it couldn't find lua.exe, after that the problem seemingly went away but I'm guessing this might have something to do with that runtime errors). I clearly must be doing something wrong, so any help would be appreciated.

pkulchenko commented 3 years ago

There should be a DLL built. Do the instructions here help: http://wxlua.sourceforge.net/docs/install.html#C4.4?

Kristopher38 commented 3 years ago

Thanks a lot, your hint to look into the DLLs got me on the right track. Turns out I was loading the wrong dll and linking against the wrong lib. Lua .dll and .lib files in wxLua-build\bin\Debug (which I had in the PATH) are copied over from the wxLua\modules\luaproxydll, and aren't the dlls that are built during building process. The ones that are, are actually in wxLua-build\bin-shared\Debug. For future reference if someone has the same problem: in the most basic setup, you need to link against wxLua-build\bin-shared\Debug\lua51.lib and wxLua-build\lib\Debug\wxlua-wx31mswud-3.1.0.0.lib, and have wxLua-build\bin\Debug and wxLua-build\bin-shared\Debug in your PATH (or have your program see the built dlls: wx.dll and lua51.dll from their respective folders).

pkulchenko commented 3 years ago

Sounds good; thank you for the update.

BTW, \Debug path may change to \Release or \MinSizeRel depending on CMAKE_BUILD_TYPE selected.