From KlayGE
Jump to: navigation, search


Before compiling KlayGE, Python 2.7+ and CMake 3.4+ must be installed first. Then you can run build_external.py to build and install third-party libraries and tools. KlayGE has been tested on these compilers.

Since KlayGE 3.12.0, include and lib paths are set up inside the project files. After extraction, just open the corresponding project file under "Build" directory, KlayGE itself can be built directly. Or you can run build_all.py to do that job.

Since KlayGE 4.1.0, project files are migrated to cmake. Several on-stop compiling scripts written in Python is also included. The build_glloader.py is used for compiling glloader; the build_kfont.py for kfont; the build_KlayGE.py for KlayGE, Samples, Tools and Tutorials. The build_all.py can build all of them. Those .py have two optional parameters. The first one is compiler name, the second one is configuration name. For example, "build_all.py vc10 x64" means uses vc10's x64 configuration for compiling. Currently, compiler names such as vc8, vc9, vc10, vc11, vc12, mingw and gcc are supported. Configuration names such as x86, x64, x86_app, and arm_app are supported. If no parameter in the command line, default parameters inside cfg_build.py will be used.

Since KlayGE 4.4.0, 3rd party libraries uses cmake as project files. You only need to run build_external.py to finish the build, not native project files provided by 3rd party libraries themselves.

Since KlayGE 4.5.0, Android and WinRT version can be build with the same cmake, too. Before that, you need a Windows version of tools. They are used in the process of building Android and WinRT version.

During the compilation, if the vc said couldn't find v110_xp toolset, please install Visual Studio 2012 Update or up.

Notes for MinGW users:

There are some incompatibilities between new versions of the Windows SDK/DirectX SDK and MinGW. When compiling the DirectSound plug-in, and the compiler will report sal.h cannot be found. VC's "sal.h" needs to be copied to "MinGW/include". Then open "MinGW/lib/gcc/mingw32/4.4.1/include/stddef.h", replace "#define NULL __null" by "#define NULL 0". Otherwise, sal.h will define __null to some other token incorrectly.

Linux platform

Take Ubuntu as an example here. You need to install wine and its dependencies.

sudo apt-get install wine wine-dev libc6-dev-i386 g++-4.8-multilib libx11-dev libgl1-mesa-dev libglu1-mesa-dev libopenal-dev build-essential

Once you have wine installed, you also have to make it into 32-bit mode. Because 64-bit wine doesn't work at all.

export WINEARCH=win32

OSX platform

If you don't have brew.sh installed, run


Wine must be installed on OSX, too.

brew cask install xquartz
brew install wine --without-win64

See Also