Compiling with MinGW (OpenXcom)
- 1 Compiling on Ubuntu 12.10 or 12.04LTS
- 2 Compiling 32bits on Windows
- 3 Compiling 32bits and 64bits on Windows
- 4 MXE
- 5 Compiling and cross-compiling OpenXcom Extended
Compiling on Ubuntu 12.10 or 12.04LTS
Install the cross-compiler
apt-get install g++-mingw-w64-i686
This is the compiler targeting Win32/x86. If you want to build a 64-bit binary, you're on your own for libraries.
Grab the source
git clone https://github.com/SupSuper/OpenXcom.git
Don't have git installed? Install it with
apt-get install git.
Download the prerequisite libraries
Building all the prerequisites from source is a good way to waste a day of your life. Some of them are availalbe in the stock package repositries, such as libsdl and libogg, but the majority are not. I recommend downloading the tarball of static libraries I've compiled.
Supposing that you've downloaded the file to ~/Downloads, install the contents with the following commands:
cd / ; tar xvJf ~/Downloads/OXC-mingw32-cross-tools.tar.xz. This will place a bunch of files in
This fileset includes a 64-bit pkg-config binary. If you need a 32-bit one, build it with the following steps:
- apt-get source pkg-config
- cd pkg-config-*
- ./configure --prefix=/usr/local/cross-tools/i386-mingw32
- sudo make install
Get the Makefile and make
Download my Makefile. It's based on Makefile.simple and Michal's gitbuilder file. Place the file in OpenXcom/src and
-lws2_32 is only needed for
ntohl(), used by the FLAC library iirc.
Compiling 32bits on Windows
Here comes a way to build OpenXcom in a Windows environment having installed only MinGW (no MSYS, no bash, no sh, no Visual IDE or compiler). There could be others way to do, this is only an example. Some directories names will change to match the libraries versions, just adapt the paths.
See the MinGW website. Install at least C compiler, C++ compiler and GNU make.
Set up your project directory with SDL
Choose your project directory. Let's call it
On SDL website download SDL 1.2 win32 development library for Mingw32.
Extract it in
<project> keeping directory hierarchy, you should get it in a directory such as
On SDL_mixer website download SDL_mixer 1.2 source and SDL_mixer 1.2 Win32 32bits binaries. Extract the source in
<project>, you should get it in a directory such as
<project>\SDL_mixer-1.2.12. Create a
<project>\SDL_mixer-1.2.12\bin directory and extract the binaries here.
On SDL_image website download SDL_image 1.2 source and SDL_image 1.2 Win32 32bits binaries. Extract the source in
<project>, you should get it in a directory such as
<project>\SDL_image-1.2.12. Create a
<project>\SDL_image-1.2.12\bin directory and extract the binaries here.
Set up SDL_gfx
On SDL_gfx website download last SDL_gfx source and extract it in
<project>. You should get it in a directory such as
<project>\SDL_gfx-2.0.24. Go to Other builds subdirectory and extract Makefile from mingw32.zip in the
<project>\SDL_gfx-2.0.24 directory. Edit the Makefile to modify it to have:
CFLAGS = -O3 -march=athlon-xp -mmmx -msse -m3dnow -DBUILD_DLL -DWIN32 -I..\SDL-1.2.15\include\SDL LIBS = -L..\SDL-1.2.15\lib -lSDL OBJS = SDL_framerate.o SDL_gfxBlitFunc.o SDL_gfxPrimitives.o SDL_imageFilter.o SDL_rotozoom.o
Then run in the
You should get a
Set up yaml-cpp
From the yaml-cpp website download a yaml-cpp source higher than 0.5.0, such as 0.5.1.
From the CMake website download the CMake Windows zip binaries distribution.
From the boost website download the current release.
Extract the three archives in <project>; you should get directories such as
Go to the
<project>\yaml-cpp-0.5.1 directory and run the following commands:
set Path=%Path%;<project>\cmake-188.8.131.52-win32-x86\bin mkdir build cd build cmake -G "MinGW Makefiles" -DBUILD_SHARED_LIBS=OFF -DBoost_INCLUDE_DIR=<project>\boost_1_54_0 .. mingw32-make
This should build a static library
There are problems building a dynamix library with the 0.5.1 version, but this could work with later versions.
Thankfully yaml-cpp does not need boost to build (it only uses the header files) because boost does not support MinGW compiling.
Build and run OpenXcom
Download the last available source and extract it in
<project> directory, you should get a
Copy original game directories in
<project>\OpenXcom-master\makefile such as this one:
PROG=OpenXCom MINGW= SRC=$(wildcard src/*.cpp src/*/*.cpp src/*/*/*.cpp) OBJRES=src\$(PROG)_res.o OBJ=$(OBJRES) $(SRC:.cpp=.o) BIN=bin\$(PROG).exe RES=src\$(PROG).rc src\resource.h src\version.h res\windows\openxcom.ico WINVER=0x0400 CXX=$(MINGW)g++ CXXFLAGS=-DWINVER=$(WINVER) -I..\SDL-1.2.15\include\SDL -I..\SDL_mixer-1.2.12 -I..\SDL_image-1.2.12 -I..\SDL_gfx-2.0.24 -I..\yaml-cpp-0.5.1\include -I..\boost_1_54_0 -Wall -Wextra -Wno-unused-function -O2 LDFLAGS=-L..\SDL-1.2.15\lib -L..\yaml-cpp-0.5.1\build -lshlwapi -lmingw32 -lopengl32 -lSDLmain ..\SDL-1.2.15\bin\SDL.dll ..\SDL_mixer-1.2.12\bin\SDL_mixer.dll ..\SDL_image-1.2.12\bin\SDL_image.dll ..\SDL_gfx-2.0.24\bin\SDL_gfx.dll -lyaml-cpp -mwindows RC=$(MINGW)windres RFLAGS= .PHONY:all compile depends mrproper clean rebuild all:compile compile:$(BIN) depends: AppDep -n -l "# Dependencies" makefile for %%i in ($(SRC:.cpp=)) do $(CXX) $(CXXFLAGS) -MM "%%i.cpp" -MT "%%i.o" >> makefile $(BIN):$(OBJ) $(CXX) $(CXXFLAGS) -o $(BIN) $(OBJ) $(LDFLAGS) $(OBJRES):$(RES) $(RC) $(RFLAGS) -o $@ $< %.o:%.cpp $(CXX) $(CXXFLAGS) -o $@ -c $< mrproper:clean for %%i in ($(BIN)) do if exist "%%~fi" del "%%~fi" clean: for %%i in ($(OBJ)) do if exist "%%~fi" del "%%~fi" rebuild:mrproper all
You can also try to produce your makefile with CMake rather than using this example.
Fill MINGW variable if you have several MinGW instances (such as a 32bits one and a 64bits one).
-g -D_DEBUG to CXXFLAGS variable to generate debug information.
AppDep utility can be downloaded here. If you don't want to use it, just add a #Dependencies line at the end of your makefile, remove the AppDep call, and clear all lines after #Dependencies before using make depends.
<project>\OpenXcom-master and run:
mingw32-make depends mingw32-make all
<project>\OpenXcom-master\bin\OpenXcom.exe should be produced.
If windres fails because of null characters, convert
src\OpenXcom.rc from UTF-16LE to ANSI.
To run the game, use the following commands in the same directory:
set Path=%Path;<project>\SDL-1.2.15\bin;<project>\SDL_mixer-1.2.12\bin;<project>\SDL_image-1.2.12\bin;<project>\SDL_gfx-2.0.24\bin bin\OpenXcom.exe -user <your name>
Compiling 32bits and 64bits on Windows
You can see instructions on how to build with MinGW-w64 in this GitHub fork of OpenXcom. (By the author of previous section).
Michal uses a different setup for his own builds and gitbuilder, based on MXE. I haven't tried MXE myself but supposedly its compiler rejects the -msse2 flag. On the other hand, it looks like it'll build all the libraries for you!