wxLua 2.8.12 - Installation Guide

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. All of the build settings and platforms that are supported by wxWidgets are supported by wxLua on these platforms.

Table of Contents

  1. 1 - Required Libraries (dependencies)
  2. 2 - Building wxWidgets
    1. 2.1 - Get the wxWidgets Source Code
    2. 2.2 - Build using Microsoft Visual Studio GUI
    3. 2.3 - Build using MSVC NMake
    4. 2.4 - Build using MinGW
    5. 2.5 - Build using GCC in Linux
    6. 2.6 - Build using GCC in OSX
  3. 3 - wxLua Components
    1. 3.1 - wxLua applications
    2. 3.2 - wxLua libraries
    3. 3.3 - wxLua utilities
  4. 4 - Building with CMake
    1. 4.1 - CMake with MSVC
    2. 4.2 - CMake with MinGW
    3. 4.3 - CMake with GCC in Linux and OSX
  5. 5 - Building on Windows
    1. 5.1 - Windows makefiles
    2. 5.2 - Visual Studio nmake
    3. 5.3 - Visual Studio IDE
  6. 6 - Building on Linux/Unix
  7. 7 - Advanced building options
    1. 7.1 - Building a minimal set of wxWidgets wrappers
    2. 7.2 - wxLua libraries and linking order

1 - Required Libraries (dependencies)

2 - Building wxWidgets

2.1 - Get 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 a 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

        ../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) and you should simply build them all.

3.1 - wxLua applications

3.2 - wxLua libraries

3.3 - wxLua Utilities

4 - Building wxLua with CMake

  1. Run the cmake-gui program.
  2. Choose the compiler you wish to use, it should match the compiler you used to compile wxWidgets.
  3. Select the root of the wxLua directory as the "Where is the source code" directory, it has the root CMakeLists.txt file in it.
  4. Select a directory, perhaps named wxLua-build, at the same level as the wxLua/ directory for "Where to build the binaries."
  5. Press the "Configure" button a few times.
  6. Choose the type of library you want, static or shared libs (DLLs) by checking the BUILD_SHARED_LIBS variable.
  7. Skip to the section below appropriate for your compiler.

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.1 - CMake with MSVC

  1. To find wxWidgets you must set the 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 
  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]
  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 wxWidgets 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.
  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 build 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.

4.2 - CMake with MinGW

  1. Choose the CMAKE_BUILD_TYPE that you want.
  2. To find wxWidgets you must set the variable wxWidgets_ROOT_DIR=/path/to/wxWidgets
  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 wxWidgets_LIB_DIR=/path/to/wxWidgets/lib/gcc_lib 
  5. Press "Configure" again, if it doesn't work set wxWidgets_CONFIGURATION=[msw, mswu]
  6. Press "Configure" again, if it doesn't work set wxWidgets_VERSION=[2.8.x,2.9.x]
  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 wxWidgets 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.3 - CMake with GCC in Linux or OSX

  1. Choose the CMAKE_BUILD_TYPE that you want.
  2. To find wxWidgets you must set the variable wxWidgets_CONFIG_EXECUTABLE=/path/to/wx-config, see above about build 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 wxWidgets 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 - Building on MS Windows using Bakefile generated buildfiles in wxLua/build

wxLua uses environment variables to tell the Windows build files where the wxWidgets and wxStEdit libraries are.

You can set these environment variables in MS Windows either at a DOS prompt by typing

or by right clicking on "My Computer" -> "System" -> "Environment Variables" and add it for yourself or for everyone. Don't forget to restart either the DOS prompt or the MSVC IDE if you change the environment variable through "My Computer."

5.1 - Windows Makefiles using the Buildfiles in wxLua/build/msw

Enter the wxLua/build/msw directory with a MSDOS prompt and run one of the commands below to build all modules, applications, and utilities of wxLua. See the sections for each compiler to learn about the available command line settings to customize how the library and executables are built.

Look at the top of the makefile for your compiler to see the available build options. You do not have to (and should not) edit the makefiles to change any setting, instead you should set them on the command line as shown below.

5.2 - Visual Studio nmake

For MSVC's nmake you will have to run the vcvars32.bat script in the DOS prompt before trying to build wxLua.

For example, Visual Studio 2008 installs it here in Windows 7:

>"c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin\vcvars32.bat"

NOTE: If you get an error about nmake.exe not found when you try to build wxLua, you need to (re)run vcvars32.bat.

The wxLua build options for nmake.exe are at the top of build/msw/makefile.vc, please review it before trying to build wxLua.

The typically used build options for wxLua using nmake.exe are:

nmake -f makefile.vc BUILD=[release/debug] UNICODE=[0/1] SHARED=[0/1] WX_SHARED=[0/1] WX_MONOLITHIC=[0/1]

Two of the most commonly used build command lines to build wxLua are:

For comparison, typical options for building wxWidgets using nmake.exe are:

nmake -f makefile.vc SHARED=[1/0] UNICODE=[1/0] MONOLITHIC=[1/0] BUILD=[release/debug]

NOTE: If you get a compiler error complaining that wx/setup.h or wx/wx.h cannot be found, this is because the default build options or the options you gave did not match any of the available wxWidgets builds. You must choose the wxLua build options BUILD, UNICODE, SHARED, WX_DIR, WX_SHARED, WX_VERSION, WX_MONOLITHIC that match one of the existing wxWidgets builds. The include file above is created by the wxWidgets build and is placed into the wxWidgets/lib/[build]/msw[d]/wx/setup.h directory.

Note that the wxLuaEdit app is not build by default; you need to enable the wxStEdit dependency by using the USE_WXLUAEDITAPP=1 option.

Some useful targets you can specify are:

5.3 - Visual Studio IDE

Open the wxLua/build/msw/wxLua.dsw project file and select the same configuration you used to build wxWidgets from the "Build->Set Active Project" menu. Now build the wxLua application right-clicking on the app_wxlua target and choosing Build (or Generate). Then just repeat this build command for the app_wxluacan and app_wxluaedit targets. the mod_XXX targets will be automatically built since they are dependency of the app_XXX targets. You may also use "Batch Build" to build multiple libraries and programs at once. In order to compile the wxLuaEdit application you must compile the wxStEdit library by using its project file with the same settings that you will use for wxLua.

6 - Unix and OSX using Configure

Quickstart: Move to the root directory of the wxLua project and type: ./configure && make to build using the wxWidgets default build settings and then execute, with root permissions (you can use su or sudo commands...):

make install

If you want more control over configure you can type ./configure --help to get a list of available options.
Note that --enable-XXX or --enable-XXX=yes enables the option and --disable-XXX or --enable-XXX=no disables it.

wxLua's configure tries to determine the wxWidgets build settings automatically using the wx-config script, but if you have multiple wxWidgets builds (you can list them using wx-config --list) you can select the build you want using the --enable-unicode, --enable-debug and --with-wxshared, --with-gtk|msw|mgl|x11|motif options. Note that you would use the --enable-unicode, --enable-debug options only if you had built wxWidgets with them. The build settings for wxLua must be identical to the ones used by wxWidgets, i.e. you cannot build wxLua in ANSI mode and try to link to a Unicode build of wxWidgets.

For example, if you have a unicode, release, shared library (as opposed to static) build of wxWidgets and want to build wxLua in unicode, release, static mode, then you can do:
./configure --enable-unicode --disable-debug --disable-shared --with-wxshared

The options --enable-wxlua-app, --enable-wxluacan-app, --enable-wxluaedit-app let you to enable or disable compiling the applications which are part of wxLua.

The options --enable-wxbindstc, --enable-wxluadebug, --enable-wxluasocket let you to enable or disable compiling the wxLua modules.

You can compile multiple coexisting wxLua builds by running wxLua's configure script in different folders; e.g. from the root wxLua directory:

mkdir mybuild && cd mybuild && ../configure && make

which puts all objects and intermediate stuff in the mybuild folder (exactly as you can do with wxWidgets). This is typically a good idea even if you only have a single build so you don't pollute the main wxLua directory with the build files.

If you do not want to install wxLua to the system directory /usr/ you can specify --prefix=/path/to/install/to and when you run make install the headers, apps, and libs will be placed there. For development purposes it is often not necessary to install wxLua, but you may need to specify the shell environment variable LD_LIBRARY_PATH to allow the executables to find the shared libraries, e.g. export LD_LIBRARY_PATH=/path/to/wxLua/lib, be careful not to override the variables existing value so you may want to instead do export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path/to/wxLua/lib.

The wxLuaEdit application depends on the wxStEdit library that you should have compiled before trying to compile wxLua. There are two ways to let wxLua's configure find the wxStEdit library: 1) Set the shell environment variable before running configure export WXSTEDIT=/path/to/wxstedit or 2) Use the --with-wxstedit-prefix=/path/to/wxstedit configure directive. As a last resort you can help wxLua's configure find wxStEdit or its libraries by exporting these environment variables:

export CPPFLAGS="-I/path/to/wxstedit/include"
export LDFLAGS="-L/path/to/wxstedit/lib"

Other useful targets which you can use are:

7 - Advanced Building

These instructions are for C++ developers who want to use wxLua as a script interpreter in their own project. This means that you can write scripts to make your code simpler, load and run files on the fly, and allow users to more easily customize your program with their own Lua scripts.

7.1 - Building a minimal set of wxWidgets wrappers

In order to embed wxLua in your project, you will probably need the library from wxLua/modules/lua and wxLua/modules/wxlua 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 get the ability to create wxWidgets objects and use the functionality of wxWidgets in Lua you will also need to build and link to the libraries in modules/wxbind. The bindings in modules/wxbind contain nearly all of the classes and functions in wxWidgets. They also contain the appropriate #if wxUSE_XXX statements and platform dependent __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 wxlua-users mailing list).

NOTE: if you want all wxWidgets API wrapped and you don't care about size of the wxLua libraries, then you can just skip this section ! You will just need to link your program against the wxLua libraries which can be built with the directions above. Just look at section 5.2 for some tips about linking order.

In order to make wxLua libraries smaller, you just need to add to your project a file named wxluasetup.h (the name must be exactly that, all lowercase!) which should start as a copy of modules/wxbind/setup/wxluasetup.h. Once you have your custom wxluasetup.h you can edit it to your liking. The 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 bindings making them smaller.

NOTE: The functionalities of wxLua bindings will obviously be limited by your current wxWidgets build settings; i.e. if you did not built OpenGL support in wxWidgets you won't have it in wxLua!

Once you have created and edited wxluasetup.h you can build your wxBind custom library: on Windows, just open an MSDOS prompt and move in the wxLua/modules/wxbind/build directory and then launch a MAKE command using the WXLUASETUP_DIR option to tell the makefile the path to your custom wxluasetup.h and the WXLUABINDLIB_DIR option to tell the makefile where the custom wxBind library should be created:
On Unix/Linux, unless you used the --enable-customwxbind-install=no option, then the wxBind sources will be installed to PREFIX/src/wxbind as soon as you give the make install command.
Once you have them installed, just go in the PREFIX/src/wxbind/build folder and type:

make -f makefile.gnu WXLUASETUP_DIR=~/myproj/include WXLUABINDLIB_DIR=~/myproj/lib

and you will get your wxBind custom library compiled.

Last step: you just need to add to your project dependencies the custom wxBind library you've just created.
Next section helps you with linking order which can be a bit troubling with some compilers.

7.2 - wxLua libraries and linking order

The order in which you link to the wxLua libraries is important since some variable are initialized using variables from other libraries. 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.

Thus the library order to give to the gcc linker is (last means initialized first):

wxbind..., wxbindcore, wxbindbase, wxluasocket, wxluadebug, wxlua, lua, wxWidgets libs

Obviously you should remove the libraries you don't use (e.g. wxluasocket, wxluadebug) and use the decorated names for the others. The wxLua makefiles/IDE outputs the libraries following the same wxWidgets naming rule:

wxlua_$(WX_PORT_WITHVERSION)$(WXLIBPOSTFIX)_wxlua-$(WX_VERSION_MAJOR).$(WX_VERSION_MINOR)

where WX_PORT_WITHVERSION can be gtk2, msw, x11, etc; WXLIBPOSTFIX can be u, d, ud.