[HowTo] Compile TrinityCore on Mac OS X using Homebrew

This tutorial aims to simplify the compilation of TrinityCore on Mac OS X by using Homebrew, the missing package manager for OS X, to install TrinityCore dependencies, in order to keep things simple.

[SIZE=18px]1) Install Homebrew[/SIZE]

For those who don’t have Homebrew installed, you can easily install it typing:

ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)”

[SIZE=18px]2) Install Xcode and Command Line Tools[/SIZE]

Install XCode using the App Store, then type:

xcodeselect --install

[SIZE=18px]3) Install dependencies[/SIZE]

brew update

brew install mysql openssl readline cmake boost zlib

brew link zlib --force

[SIZE=18px]4) Getting sources[/SIZE]

Move to the folder where you want to place the TrinityCore sources, then type:

git clone https://github.com/TrinityCore/TrinityCore.git

cd TrinityCore

If ( and [B]ONLY[/B] if ) you want to compile 3.3.5 type:

git checkout 3.3.5

Create build folder:

mkdir build

cd build

[SIZE=18px]5) Generate the XCode project files[/SIZE]

IMPORTANT: replace /Users/username/tc-server of the following command with the path where you want to install the TrinityCore server.

then type:

cmake …/ -GXcode
-DMYSQL_ADD_INCLUDE_PATH=/usr/local/include
-DMYSQL_LIBRARY=/usr/local/mysql/lib/libmysqlclient_r.dylib
-DREADLINE_INCLUDE_DIR=/usr/local/opt/readline/include
-DREADLINE_LIBRARY=/usr/local/opt/readline/lib/libreadline.dylib
-DBOOST_INCLUDEDIR=/usr/local/include
-DBOOST_LIBRARYDIR=/usr/local/lib
-DOPENSSL_INCLUDE_DIR=/usr/local/opt/openssl/include
-DOPENSSL_SSL_LIBRARIES=/usr/local/opt/openssl/lib/libssl.dylib
-DOPENSSL_CRYPTO_LIBRARIES=/usr/local/opt/openssl/lib/libcrypto.dylib
-DZMQ_LIBRARY=/usr/local/opt/zeromq/lib/libzmq.dylib
-DZMQ_INCLUDE_DIR=/usr/local/opt/zeromq/include
-DZLIB_ROOT=/usr/local/Cellar/zlib/1.2.8
-DCMAKE_INSTALL_PREFIX=/Users/username/tc-server
-DWITH_WARNINGS=1

[SIZE=18px]6) Building the binaries[/SIZE]

Type the following to build the binaries:

xcodebuild -target install -config Release

I have tested this tutorial both for branch [B]3.3.5[/B] and [B]6.x[/B] using a [B]MacBook Pro Retina 15"[/B] running:
  • a fresh Mac OS X 10.9.5 (Mavericks)

  • a fresh Mac OS X 10.10.3 (Yosemite)

  • Mac OS X 10.11.3 (El Capitan)

and it worked fine, give me your feedback.

Thanks dude, since I ditched Windows I mainly use Linux, but I also have a Macbook, so this was a great help.

Hmm I got a problem, I don’t know where it comes from. Maybe my fault, but I’ve done everything like you.

Ld build/src/server/worldserver/Debug/worldserver normal x86_64
cd /Users/Kevin/work/TrinityCore/TC
export MACOSX_DEPLOYMENT_TARGET=10.9
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -L/Users/Kevin/work/TrinityCore/TC/build/src/server/worldserver/Debug -F/Users/Kevin/work/TrinityCore/TC/build/src/server/worldserver/Debug -filelist /Users/Kevin/work/TrinityCore/TC/build/src/server/worldserver/TrinityCore.build/Debug/worldserver.build/Objects-normal/x86_64/worldserver.LinkFileList -mmacosx-version-min=10.9 -pthread -Wl,-search_paths_first -Wl,-headerpad_max_install_names /Users/Kevin/work/TrinityCore/TC/build/src/server/game/Debug/libgame.a /Users/Kevin/work/TrinityCore/TC/build/src/server/shared/Debug/libshared.a /Users/Kevin/work/TrinityCore/TC/build/src/server/scripts/Debug/libscripts.a /Users/Kevin/work/TrinityCore/TC/build/src/server/collision/Debug/libcollision.a /Users/Kevin/work/TrinityCore/TC/build/dep/g3dlite/Debug/libg3dlib.a /Users/Kevin/work/TrinityCore/TC/build/dep/gsoap/Debug/libgsoap.a /usr/local/opt/readline/lib/libreadline.dylib /usr/local/lib/libACE.dylib /usr/local/lib/libmysqlclient_r.dylib /usr/local/opt/openssl/lib/libssl.dylib /usr/local/opt/openssl/lib/libcrypto.dylib /usr/lib/libz.dylib /usr/lib/libcrypto.dylib /Users/Kevin/work/TrinityCore/TC/build/src/server/shared/Debug/libshared.a /usr/local/lib/libACE.dylib -Xlinker -dependency_info -Xlinker /Users/Kevin/work/TrinityCore/TC/build/src/server/worldserver/TrinityCore.build/Debug/worldserver.build/Objects-normal/x86_64/worldserver_dependency_info.dat -o /Users/Kevin/work/TrinityCore/TC/build/src/server/worldserver/Debug/worldserver
clang: warning: argument unused during compilation: ‘-pthread’
0 0x100b60bc1 __assert_rtn + 144
1 0x100b9cbbf archive::File<x86_64>::makeObjectFileForMember(archive::File<x86_64>::Entry const*) const + 1145
2 0x100b9c588 archive::File<x86_64>::justInTimeforEachAtom(char const*, ld::File::AtomHandler&) const + 122
3 0x100bb21e3 ld::tool::InputFiles::searchLibraries(char const*, bool, bool, bool, ld::File::AtomHandler&) const + 215
4 0x100bbac9c ld::tool::Resolver::resolveUndefines() + 160
5 0x100bbcf6f ld::tool::Resolver::resolve() + 79
6 0x100b61737 main + 689
7 0x7fff97ead5fd start + 1
A linker snapshot was created at:
/tmp/worldserver-2014-09-01-091734.ld-snapshot
ld: Assertion failed: (memberIndex != 0), function makeObjectFileForMember, file /SourceCache/ld64/ld64-241.8/src/ld/parsers/archive_file.cpp, line 355.
clang: error: linker command failed with exit code 1 (use -v to see invocation)

** BUILD FAILED **

The following build commands failed:
Ld build/src/server/worldserver/Debug/worldserver normal x86_64
(1 failure)

With the cmake :

cmake .. -GXcode -DPREFIX=/Users/Kevin/work/TrinityCore/TC-devtest -DMYSQL_ADD_INCLUDE_PATH=/usr/local/include -DMYSQL_LIBRARY=/usr/local/lib/libmysqlclient_r.dylib -DREADLINE_INCLUDE_DIR=/usr/local/opt/readline/include -DREADLINE_LIBRARY=/usr/local/opt/readline/lib/libreadline.dylib -DBOOST_INCLUDEDIR=/usr/local/include -DBOOST_LIBRARYDIR=/usr/local/lib -DOPENSSL_INCLUDE_DIR=/usr/local/opt/openssl/include -DOPENSSL_SSL_LIBRARIES=/usr/local/opt/openssl/lib/libssl.dylib -DOPENSSL_CRYPTO_LIBRARIES=/usr/local/opt/openssl/lib/libcrypto.dylib -DWITH_WARNINGS=0 -DWITH_COREDEBUG=1

It’s the same, it’s just a symbolic link to avoid the version number in the path. But just in case I’ll do like you.

EDIT: In fact I used -DSCRIPTS=0 and it’s a success :confused: Something wrong in the scripts maybe.

But I think this way is the most simple for OS X

You’re right, I edited my first post using these symbolic links.

Then probabily you have some custom script which is causing the issue, for me it’s working without -DSCRIPTS=0 (just tested on a clean latest TC).

Hey,

this looks like linker errors, so cpp files are already build at this time. I don’t think it’s related to custom code (if there is some…)

Regards,

Gacko

Using macports (installing to /opt/local):

port install cmake boost zmq mysql55 openssl
CMAKE_PREFIX_PATH=/opt/local/
MYSQL_HOME=/opt/local/lib/mysql55
cmake $source_dir
-DUSE_COREPCH=0
-DUSE_SCRIPTPCH=0
given 6.x at 774e22ec.

I’ve updated the Installation Guide with Homebrew details, if you see something wrong, please report it asap.

Can anyone give me hand with this? I’ve tried with both the homebrew and following the guide and I can’t get by this error:

Cmake Error at CMakelists.txt:12

No CMAKE_C_COMPLIER could be found.

Then it tells me to look into CMakeError.log and this is what it says:

/Users/me/trinity2/TrinityCore/build/CMakeFiles/3.2.2/CompilerIdCXX/CMakeCXXCompilerId.cpp:159:10: error: macro names must be identifiers

define /me/trinity3/COMPILER_VERSION_MAJOR DEC(clang_major)

     ^

/Users/me/trinity2/TrinityCore/build/CMakeFiles/3.2.2/CompilerIdCXX/CMakeCXXCompilerId.cpp:160:10: error: macro names must be identifiers

define /me/trinity3/COMPILER_VERSION_MINOR DEC(clang_minor)

     ^

/Users/me/trinity2/TrinityCore/build/CMakeFiles/3.2.2/CompilerIdCXX/CMakeCXXCompilerId.cpp:161:10: error: macro names must be identifiers

define /me/trinity3/COMPILER_VERSION_PATCH DEC(clang_patchlevel)

     ^

/Users/me/trinity2/TrinityCore/build/CMakeFiles/3.2.2/CompilerIdCXX/CMakeCXXCompilerId.cpp:167:10: error: macro names must be identifiers

define /me/trinity3/COMPILER_VERSION_TWEAK DEC(apple_build_version)

     ^

4 errors generated.

** BUILD FAILED **

The following build commands failed:
CompileC ./CompilerIdCXX.build/Debug/CompilerIdCXX.build/Objects-normal/i386/CMakeCXXCompilerId.o CMakeCXXCompilerId.cpp normal i386 c++ com.apple.compilers.llvm.clang.1_0.compiler

I’m doing this on 10.7 Lion with xcode 4.6.3 and command line tools 4.6.2.

Tutorial updated for Mac OS X 10.10.x “Yosemite”.

[COLOR=rgb(34,34,34)]it’s work !

Tutorial updated for 6.x too.

Note: Debug mode isn’t working with 6.x #14689 so use Release.

Thanks so much!

Before compiling i see this:

  • Build map/vmap tools : No (default)

How can i change this?

Also i want to compile just 3.3.5

So i’ve checked out that branch with this command

git checkout 3.3.5
Then i’ve compiled this this:

[COLOR=rgb(0,0,0)]xcodebuild [COLOR=rgb(102,102,0)]-[COLOR=rgb(0,0,0)]target install [COLOR=rgb(102,102,0)]-[COLOR=rgb(0,0,0)]config [COLOR=rgb(102,0,102)]3.3.5Is it right? Thanks!

PS: BRAVOOO

@ikir

Ciao!

In order to enable map/vmap tools, just add the option:

Per abilitare l’opzione map/vmap tools, aggiungi semplicemente l’opzione:

-DTOOLS=1

The correct xcodebuild command is:

Il comando xcodebuild corretto è:

[COLOR= rgb(0, 0, 0)]xcodebuild [COLOR= rgb(102, 102, 0)]-[COLOR= rgb(0, 0, 0)]target install [COLOR= rgb(102, 102, 0)]-[COLOR= rgb(0, 0, 0)]config DebugOr:

Oppure:

[COLOR= rgb(0, 0, 0)]xcodebuild [COLOR= rgb(102, 102, 0)]-[COLOR= rgb(0, 0, 0)]target install [COLOR= rgb(102, 102, 0)]-[COLOR= rgb(0, 0, 0)]config ReleaseSo you can choose to compile in Debug or Release mode

Così puoi scegliere se compilare in modalità Debug o Release.

@Shin Thanks so much! Grazie mille!

But i got this error during compiling:

Ld build/src/server/authserver/Release/authserver normal x86_64
cd /Users/ikirserver/Downloads/TrinityCore
export MACOSX_DEPLOYMENT_TARGET=10.10
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk -L/Users/ikirserver/Downloads/TrinityCore/build/src/server/authserver/Release -F/Users/ikirserver/Downloads/TrinityCore/build/src/server/authserver/Release -filelist /Users/ikirserver/Downloads/TrinityCore/build/src/server/authserver/TrinityCore.build/Release/authserver.build/Objects-normal/x86_64/authserver.LinkFileList -mmacosx-version-min=10.10 -Wl,-search_paths_first -Wl,-headerpad_max_install_names /Users/ikirserver/Downloads/TrinityCore/build/src/server/shared/Release/libshared.a /Users/ikirserver/Downloads/TrinityCore/build/dep/cppformat/Release/libformat.a /usr/local/mysql/lib/libmysqlclient_r.dylib /usr/local/opt/openssl/lib/libssl.dylib /usr/local/opt/openssl/lib/libcrypto.dylib /usr/local/lib/libboost_system.dylib /usr/local/lib/libboost_filesystem.dylib /usr/local/lib/libboost_thread.dylib /usr/local/lib/libboost_program_options.dylib /usr/local/lib/libboost_iostreams.dylib -Xlinker -dependency_info -Xlinker /Users/ikirserver/Downloads/TrinityCore/build/src/server/authserver/TrinityCore.build/Release/authserver.build/Objects-normal/x86_64/authserver_dependency_info.dat -o /Users/ikirserver/Downloads/TrinityCore/build/src/server/authserver/Release/authserver
clang: error: no such file or directory: ‘/usr/local/mysql/lib/libmysqlclient_r.dylib’

** BUILD FAILED **

The following build commands failed:
Ld build/src/server/authserver/Release/authserver normal x86_64
(1 failure)

Ahhh it seems my libmysqlclient_r.dylib is in another dir /usr/local/lib/

Now everything is working!

I get the following error while compiling on El Capitan:

/Users/*******/TrinityCore/src/server/game/Server/Packets/BattlePetPackets.cpp:84:18: fatal error:
use of overloaded operator ‘<<’ is ambiguous (with operand types
‘WorldPacket’ and ‘size_type’ (aka ‘unsigned long’))
_worldPacket << Pets.size();
UPDATE:

Since zlib wasn’t in the El Captain’s default homebrew repo, I had to brew tap homebrew/dupes, in order to add it, and then install it - after that, the build went fine.

Doesn’t seem to work anymore with OS X El Capitan. I get the following message when doing the compilation:

Detected version of Boost is too old. Requested version was 1.49 (or

newer).

I tried installing boost using home-brew as above, and I am not sure how to get the newest version of boost to install correctly. Any ideas?

Doesn’t seem to work anymore with OS X El Capitan. I get the following message when doing the compilation:

Detected version of Boost is too old. Requested version was 1.49 (or

newer).

I tried installing boost using home-brew as above, and I am not sure how to get the newest version of boost to install correctly. Any ideas?

Doesn’t seem to work anymore with OS X El Capitan. I get the following message when doing the compilation:

Detected version of Boost is too old. Requested version was 1.49 (or

newer).

I tried installing boost using home-brew as above, and I am not sure how to get the newest version of boost to install correctly. Any ideas?

Linking issue. Problem resolved.