I'm planning to create a new C++ project, write some C++ functions in it, embed a Lua engine with wxLua into it, make my C/C++ functions available to a Lua side and then write my main program (including the GUI) in Lua.
My IDE/compiler are Code::Blocks/GCC on Windows. I want to compile it for Windows, Linux and OSX.
My issues:
I read a lot of documentation on wxLua and found that you should probably use wxWidgets 2.8.12 and Lua 5.2.3 (as they are the two latest stable and supported versions).
If possible, I'd like the program to be a standalone executable in the end.
So I guess I need to compile Lua and wxWidgets as .lib libraries (Windows) and .a libraries (Linux/OSX), is that correct? How would I do that?
Once that is done, what kind of project do I need to create and how would I embed wxLua into that project? I couldn't find a lot of information on that.
And finally, how would I tell my IDE/project/makefile(?) which libraries to use for which OS?
Here are my instructions on how I compile wxwidgets/wxlua on Windows/OSX/Linux for my cross-platform project, but I use gcc/mingw-tdm and not Code::Blocks, so you may need to adapt them to your environment.
Here is how you can build wxwidgets on Windows:
./configure --prefix="$INSTALL_DIR" --disable-shared --enable-unicode \
--enable-compat28 \
--with-libjpeg=builtin --with-libpng=builtin --with-libtiff=no --with-expat=no \
--with-zlib=builtin --disable-richtext \
CFLAGS="-Os -fno-keep-inline-dllexport" CXXFLAGS="-Os -fno-keep-inline-dllexport"
make
make install
This is how you can build wxlua on Windows:
cmake -G "MSYS Makefiles" -DCMAKE_INSTALL_PREFIX="$INSTALL_DIR" -DCMAKE_BUILD_TYPE=MinSizeRel -DBUILD_SHARED_LIBS=FALSE \
-DwxWidgets_CONFIG_EXECUTABLE="$INSTALL_DIR/bin/wx-config" \
-DwxWidgets_COMPONENTS="stc;html;aui;adv;core;net;base" \
-DwxLuaBind_COMPONENTS="stc;html;aui;adv;core;net;base" -DwxLua_LUA_LIBRARY_USE_BUILTIN=FALSE \
-DwxLua_LUA_INCLUDE_DIR="$INSTALL_DIR/include" -DwxLua_LUA_LIBRARY="$INSTALL_DIR/lib/lua51.dll" .
(cd modules/luamodule; make)
(cd modules/luamodule; make install/strip)
You'll need to update wxlua build instructions to use Lua5.2 instead of Lua5.1 I'm using.
I have working build scripts for Windows, OSX, and Linux in this repository. The scripts have been tested on the latest wxwidgets and wxlua versions (use trunks of both repositories). They generate one wxlua library linked against Lua dll (on Windows), so it's not quite a static configuration you may be looking for, but having static build may prevent you from loading other Lua libraries (unless you export proper symbols and provide a proxy DLL as described here), so I don't recommend that configuration.
Also, I'm still using Lua5.1 with wxlua and wxwidgets as this allows me to use LuaJIT as a drop-in replacement to get better performance in some cases. You won't have this option if you compile wxlua with Lua 5.2 as their ABI is different.
In terms of integration with your own C++-based toolkit, the best option is probably expose it as a Lua library and load from wxlua application as you'd load any other library as it allows you to keep your components independent of each other.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With