This document describes how to build the wxLua libraries, editors, and interpreters. wxLua is written in C and C++ and can be built on MS Windows, Linux, and OSX with the Visual Studio, Borland, Watcom, MingW, and GCC compilers. Most of the build settings and platforms that are supported by wxWidgets are supported by wxLua.

Table of Contents

  1. Required Libraries (dependencies)
    1.1 Recommended build settings
  2. Building wxWidgets
    2.1 Getting the wxWidgets Source Code
    2.2 Build using Microsoft Visual Studio GUI
    2.3 Build using MSVC NMake
    2.4 Build using MinGW
    2.5 Build using GCC in Linux
    2.6 Build using GCC in OSX
  3. wxLua Components
    3.1 wxLua applications
    3.2 wxLua libraries
    3.3 wxLua utilities
  4. Building wxLua
    4.1 Getting the wxLua Source Code
    4.2 Initial CMake Setup
    4.3 CMake Configuration Variables
    4.4 CMake with MSVC
    4.5 CMake with MinGW
    4.6 CMake with GCC in Linux and OSX
  5. Advanced building options
    5.1 Building a minimal set of wxWidgets wrappers
    5.2 Embedding wxLua into a C++ Application
    5.2 wxLua libraries and linking order

1 - Required Libraries (dependencies)

wxWidgets - Version 2.8.x or 2.9.x

wxSTEdit - Version 1.2.6 or higher.

Lua - Version 5.1, 5.2, or LuaJIT

2 - Building wxWidgets

wxWidgets is fairly easy to build from its source code. You should build it yourself in MS Windows and in OSX using the instructions below, refering to the wxWidgets documentation as needed. In Linux, you can use the precompiled development distribution packages, if available, or build it yourself.

2.1 - Getting the wxWidgets Source Code

2.2 - Build using Microsoft Visual Studio GUI

  1. Right-click on the main "Solution" to bring up the menu.
  2. Select "Properties..." to get the properties dialog.
  3. Select "Configuration Properties" on the left.
  4. Then the "Configuration Manager..." button in the top-right to get another dialog.
  5. Drop down the "Active Solution Platform" choice and select "x64" and copy settings from "Win32" and check "Create new project platforms."

2.3 - Build using MSVC NMake

2.4 - Build using MinGW

2.5 - Build using GCC in Linux

        glibc-headers
        cairo, cairo-devel
        GConf2, GConf2-devel
        gstreamer, gstreamer-devel, gstreamer-plugins-base, gstreamer-plugins-base-devel
        gtk2, gtk2-devel
        libjpeg, libjpeg-devel
        libpng, libpng-devel
        libtiff, libtiff-devel
        libXinerama, libXinerama-devel
        mesa-libGL, mesa-libGL-devel, mesa-libGLU, mesa-libGLU-devel
        pango, pango-devel
    ../configure --prefix=$PWD \
                 --enable-gtk2 \
                 --enable-unicode \
                 --enable-shared \
                 --enable-optimise=no \
                 --enable-mem_tracing=no \
                 --enable-profile=no \
                 --with-dmalloc=no \
                 \
                 --enable-debug \
                 --enable-debug_flag \
                 --enable-debug_info \
                 --enable-debug_gdb \
                 --enable-debug_cntxt \
                 \
                 --with-sdl \
                 --with-gnomeprint \
                 \
                 --with-opengl \
                 --enable-sound \
                 --enable-mediactrl \
                 --enable-graphics_ctx \
                 --enable-controls \
                 --enable-dataviewctrl 2>&1 | tee configure-gtk2ud.log

2.6 - Build using GCC in OSX

    ../configure --prefix=$PWD \
                 --with-osx-cocoa \
                 --enable-unicode \
                 --disable-shared \
                 --enable-optimise=no \
                 --enable-mem_tracing=no \
                 --enable-profile=no \
                 --with-dmalloc=no \
                 \
                 --enable-debug \
                 --enable-debug_flag \
                 --enable-debug_info \
                 --enable-debug_gdb \
                 --enable-debug_cntxt \
                 \
                 --with-opengl \
                 --enable-sound \
                 --enable-mediactrl \
                 --enable-graphics_ctx \
                 --enable-controls \
                 --enable-dataviewctrl 2>&1 | tee configure-osx2ud.log

3 - wxLua Components

wxLua has three components: applications (wxLua/apps), modules (wxLua/modules), and utilities (wxLua/utils). You should simply build them all.

3.1 - wxLua applications

3.2 - wxLua libraries

3.3 - wxLua Utilities

4 - Building wxLua

wxLua uses uses CMake as its build system. The CMakeLists.txt files describe how wxLua is to be built so that when CMake is run it can generate the appropriate build files for the compiler of your choice.

There is also a Makefile.wx-config in the root directory of the wxLua that can be used to build wxLua using GCC in Linux. It simply requires that the wxWidgets wx-config script is in the path to work. These files are kept as a backup, they work, but the CMake build is preferred since it is far more flexible.

4.1 - Getting the wxLua Source Code

4.2 - Initial CMake Setup

  1. Install CMake version >= 2.8
  2. Run the cmake-gui program.
  3. Choose the compiler you wish to use, it should match the compiler wxWidgets was compiled with.
  4. Select the root of the wxLua directory as the "Where is the source code" directory, it has the root CMakeLists.txt file in it and subdirectories of apps, art, bindings, modules, ....
  5. Select a directory, perhaps named wxLua-build, at the same level as the wxLua/ directory for "Where to build the binaries."
  6. Choose the type of library you want, static or shared libs (DLLs), by setting the BUILD_SHARED_LIBS variable.
  7. Press the "Configure" button a few times.
  8. Adjust the CMake variable wxWidgets_COMPONENTS to match what wxWidgets libraries you have and want to use.
  9. Adjust the CMake variable wxLuaBind_COMPONENTS to match or have fewer libraries than the wxWidgets_COMPONENTS list.
  10. Review the available settings in section 4.3 before continuing.
  11. Skip to the section below that is appropriate for your compiler to complete the build process.

ALWAYS CONFIGURE CMAKE MORE THAN ONCE to ensure that wxWidgets is properly found and the wxLua settings are synced to it.
This also applies to the command-line cmake configuration too. Double check the cmake output to ensure that wxLua will be built to your specifications.

4.3 - CMake Configuration Variables

Below are the CMake variables that you can and in some cases must adjust to build wxLua. If you want to run CMake from the command line you would specify these variables as : cmake -DBUILD_SHARED_LIBS=TRUE ...

MS Windows configuration options

Linux and OSX configuration options

4.4 - CMake with MSVC

  1. To find wxWidgets you must set the CMake variable
    • wxWidgets_ROOT_DIR=/path/to/wxWidgets
  2. Press "Configure," but it probably won't work just yet.
  3. To find the libraries for wxWidgets (you may have compiled a variety of them) you must also set the variable
    • wxWidgets_LIB_DIR=/path/to/wxWidgets/lib/vc_lib
    • Where you must set vc_lib appropriately; vc_amd64 for 64-bit, vc_dll for DLLs, and vc_amd64_dll for 64-bit DLLs
  4. Press "Configure" again, if it doesn't work set
    • wxWidgets_CONFIGURATION=[msw, mswu]
  5. Press "Configure" again, if it doesn't work set
    • wxWidgets_VERSION=[2.8.x,2.9.x]
    • Where you will use the actual number, 2.8.12 or 2.9.4 for example.
  6. If "Configure" still doesn't work, then something is wrong with your wxWidgets build... go back and fix it.
  7. If "Configure" succeeds, the output window should say "Configuring done" and the log should have a complete description of your wxLua build.
  8. Press "Generate" to have CMake write out the build files.
  9. Open wxLua.sln in the build directory...
  10. Choose the "Solution Configuration" (Debug, Release, MinSizeRel, RelWithDebInfo) that matches your wxWidgets build and build everything.
    • Note that you MUST have built wxWidgets in debug for a wxLua Debug build, but a wxWidgets release build works with a wxLua Release, MinSizeRel, RelWithDebInfo build.
  11. All the apps are put into build\bin\Debug or Release, MinSizeRel, RelWithDebInfo as appropriate.
  12. Right-click on "wxLua_app" and select as "Startup project" and press the "Start Debugging" program to run it in the GUI... etc.
  13. If you built as a DLL using the wxWidgets DLLs you will have to either have the wxWidgets DLLs in you PATH environment variable or copy them into the same directory as the wxLua executables.
    • If you run a program and it silently closes with no error you can open a cmd.exe (DOS) prompt and run it there and, if you're lucky, an error message about a missing DLL will be printed to the console.

4.5 - CMake with MinGW


  1. Choose the CMAKE_BUILD_TYPE that you want.
  2. To find wxWidgets you must set the variable
  3. Press "Configure," but it probably won't work just yet.
  4. To find the libraries for wxWidgets (you may have compilied a variety of them) you must also set the variable
  5. Press "Configure" again, if it doesn't work set
  6. Press "Configure" again, if it doesn't work set
  7. If "Configure" still doesn't work, then something is wrong with your wxWidgets build... go back and fix it.
  8. If "Configure" succeeds, the output window should say "Configuring done" and the log should have a complete description of your wxLua build.
  9. Press "Generate" to have CMake write out the build files.
  10. Open a cmd.exe prompt to run mingw32-make.exe help to display all the available targets.
  11. If you run mingw32-make.exe with no parameters you will build everything, which is probably best.
  12. All the apps are put into build\bin\Debug or Release, MinSizeRel, RelWithDebInfo as appropriate.

4.6 - CMake with GCC in Linux or OSX

  1. Choose the CMAKE_BUILD_TYPE that you want.
    • Note that the CMake Makefile generator requires separate directories for each Debug, Release, MinSizeRel, and RelWithDebInfo builds.
  2. To find wxWidgets you must set the variable
    • wxWidgets_CONFIG_EXECUTABLE=/path/to/wx-config
    • See above about building wxWidgets for Linux for a description of it.
  3. Press "Configure" and the output window should say "Configuring done" and the log should have a complete description of your wxLua build.
  4. Press "Generate" to have CMake write out the build files.
  5. Open a terminal, change into your wxLua build dir and run make help to display all the available targets.
  6. If you run make with no parameters you will build everything, which is probably best.
  7. All the apps are put into build\bin\Debug or Release, MinSizeRel, RelWithDebInfo as appropriate.
  8. You can run all the apps without installing them.

5 - Advanced Building

These instructions are for developers who wish to customize wxLua's wxWidgets bindings or for those who want to use wxLua as a script interpreter in their own C++ project.

5.1 - Building a minimal set of wxWidgets wrappers

The functionality of wxLua's wxWidgets bindings are limited by your wxWidgets build settings; i.e. if you built wxWidgets with wxUSE_TIMER=0 then you will not be able to use the wxTimer class in wxLua.

If you want all of the wxWidgets API that's available in your wxWidgets build wrapped by wxLua, simply build wxLua using the directions above, no modifications required.

On the other hand, if you wish to make the wxLua bindings smaller, you will need to set the CMake variable wxLuaBind_WXLUASETUP_DIR to point to the directory with a customized wxluasetup.h header copied from modules/wxbind/setup/wxluasetup.h. It is best to copy it to a new directory instead of modifying the original one. This way you will have the original as a backup to compare your changes to.

The wxluasetup.h header file contains a number of wxLUA_USE_XXX #defines that are fairly self explanitory. By setting some of them to 0 you can block out large chunks of the wxWidgets bindings making the library smaller.

Be careful about which parts you remove since you can badly cripple your ability to create and use higher-level objects if you disable the lower-level parts they rely on. Though, this may be your goal, some experimentation may be required.

Once you have created and edited your wxluasetup.h you can build your custom wxLuaBind library following the directions above.

5.2 - Embedding wxLua into a C++ Application

In order to embed wxLua in your project, you will need the wxLua/modules/lua and wxLua/modules/wxlua libraries at a minimum. With these two libraries you have the ability to start an interpreter and run straight Lua code in it using the wxLuaState class.

To enable creation and use of wxWidgets objects in Lua you will also need to build and link to the libraries in modules/wxbind. The wxWidgets bindings contain the appropriate #if wxUSE_XXX statements and platform dependent #ifdef __WXMSW/GTK/MAC__ checks that wxWidgets uses in its headers to ensure that no matter what platform or what type of build you use, the bindings will compile without errors (if they don't compile for your settings, please be sure to tell us on the ).

5.3 - wxLua libraries and linking order

The order in which you link to the wxLua libraries is important. You must always link to any binding library after (in terms of initialization) linking with the wxLua libraries.

NOTE: Many linkers actually link libraries in the opposite order in which they appear on the command line. This means that the libraries that are first in the linker list are initialized last.