Difference between revisions of "Compile for Windows"

From UFO:AI
(Added 2.6-dev MSYS2+C::B build instructions)
m ("32bit only" is a Windows only restriction AFAIK)
Line 9: Line 9:
 
==== MSYS2 ====
 
==== MSYS2 ====
  
Download and install i686 version of MSYS2 and update its package repository via '''pacman''' as described on their {{https|www.msys2.org/|homepage}}. At time of writting UFO:AI compiles in 32bit mode only.
+
Download and install i686 version of MSYS2 and update its package repository via '''pacman''' as described on their {{https|www.msys2.org/|homepage}}. At time of writting UFO:AI for Windows compiles in 32bit mode only.
  
  

Revision as of 00:05, 22 April 2018

Building UFO:AI 2.6-dev

To compile UFO:AI you need to set up a build environment: a compiler, linker, the necessary libraries and headers; then compile the sources. Compiling can happen from command-line or using IDEs (Integrated Development Environments)

Build environment

MSYS2

Download and install i686 version of MSYS2 and update its package repository via pacman as described on their homepage. At time of writting UFO:AI for Windows compiles in 32bit mode only.


Using MSYS console run the following command to install dependencies:

$ pacman -S mingw-w64-SDL2 mingw-w64-SDL2_mixer mingw-w64-SDL2_ttf mingw-w64-libtheora \
  mingw-w64-libjpeg-turbo mingw-w64-libpng mingw-w64-curl mingw-w64-xvidcore mingw-w64-libxml2 \
  mingw-w64-openal mingw-w64-make mingw-w64-gcc mingw-w64-gdb mingw-w64-binutils mingw-w64-glib2 \
  mingw-w64-gtk2 mingw-w64-gtkglext mingw-w64-gtksourceview2 mingw-w64-atk mingw-w64-pkg-config \
  mingw-w64-bash mingw-w64-lua51 mingw-w64-googletest

IDE / compile

Code::Blocks

Download and install (or extract if you prefer the nosetup variant) of Code::Blocks from CodeBlocks.org but DO NOT launch it yet.

We have to help Code::Blocks to find the MinGW-W64 compiler and it's includes/libraries. The easiest way to do this is adding new compiler definitions via the new(ish) XML interface. If you Code::Blocks launched already it generated a configuration file and it won't load available compilers from the XMLs.

Add compiler_mingw-w64-i686.xml and options_mingw-w64-i686.xml to share\CodeBlocks\compilers\ directory under Code::Blocks' installation path.

Add MSYS/MinGW-W64 bin directory to the PATH environment variable. This makes sure Code::Blocks will find the compiler, also that the game find the DLLs it need. Depending on your Windows version there are different ways to set the PATH environment variable. It is also an option to create a batch script to start Code::Blocks with the PATH extended for that session only: (change paths to fit your installation)



codeblocks.bat

SET PATH=%PATH%;C:\msys32\mingw32\bin\;

"C:\Program Files (x86)\CodeBlocks\codeblocks.exe"



Start Code::Blocks, it should find and suggest using the MinGW-W64 i686 compiler.

If you plan to contribute, please read our Coding_guidelines and configure Code::Blocks properly.


Click File/Open and load build/projects/ufo.workspace from your Git clone (Getting the source if you don't have it yet). This will load the individual project files from the same directory.

Hit Ctrl F9 to compile or Ctrl F11 to recompile all.


Building UFO:AI 2.5 and earlier

(Old documentation, feedback is welcome) You must first compile the source code. We recommend using Code::Blocks for this. There is also an (experimental) compile guide using Eclipse CDT with MSYS/MinGW. More instructions can be found here: