MinGW GCC toolchain (Win)

This guide is not updated for recent versions of TrinityCore that use C++11.


Introduction

This guide is directed towards advanced Windows users who, for some reason, want to use GCC instead of Visual Studio to build TC. Regular users should build TC using the basic guide, as using GCC has no benefit for them over the VS solution. Therefore this guide won't provide step-by-step instructions most of the time. This guide only covers only compiling the source code. For other steps about setting up your TrinityCore installation, please refer to the How to: Windows guide.

Preparation

To successfully build TC with mingw GCC toolchain you need (in addition to requirements from the basic guide):

  • MinGW - there are several MinGW distributions around the Net, this guide uses http://www.mingw.org/ , which outputs only 32 bit code. Please install your favourite distro according to the documentation provided with it. For mingw.org the documentation is here: http://www.mingw.org/wiki/Getting_Started .
  • MSYS - a convenient bash shell for windows, please follow the install guide for details.

Libraries for MinGW

The libmysql.lib file provided with your MySQL installation cannot be used by the MinGW GCC toolchain, because GCC expects libraries with the '.a' format. The simplest way to fix the problem is to convert the .lib file provided with your install. You can do that by doing the following in MSYS:

Inside MSYS shell please do:

cd /to/your/mysql/install/directory

cd lib/opt

reimp.exe -d libmysql.lib
dlltool.exe -k -d libmysql.def -l libmysql.a

Note

If your mingw installation does not provide reimp or dlltool, you need to download them, for example from here.

If you are getting errors with the reimp command, you may need to rebuild the mingw-utils-0.4-1 package from source as the binary distribution contains a bug.

Build

Once you have done the previous steps, you can proceed to build the code:

cd /to/directory/you/want/to/build/in #building in the trinitycore source dir is not advised

#the following should be in a single command (1 line)

cmake -G"MSYS Makefiles" -DUSE_COREPCH=0 -DUSE_SCRIPTPCH=0 #build with PCH enabled is not supported

-DUSE_MYSQL_SOURCES=0 -DMYSQL_INCLUDE_DIR=[/path/to/mysql/distribution/]/include -DMYSQL_LIBRARY=[/path/to/mysql/distribution/]/lib/opt/libmysql.a # path to include dir of your mysql distro and to libmysql.a you just created

-DCMAKE_INSTALL_PREFIX=/where/you/want/to/put/installed/tc

/path/to/trinitycore/dir

#end of cmake command

make # this will take a (long) while

make install # this will install the software in your preferred directory. Afterwards, you can run 'make uninstall' to remove and make clean to purge build directory.

Running the core

Executables were built with dependencies on mingw, so you need to make sure to add mingw/bin dir to your PATH variable. Also, remember to copy the libmysql.dll file to the install directory, or add it to the PATH as well.