Shin

[HowTo] Compile TrinityCore on Mac OS X using Homebrew

39 posts in this topic

 

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.

 

1) Install Homebrew

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)"

 

2) Install Xcode and Command Line Tools

Install XCode using the App Store, then type:

xcodeselect --install

 

3) Install dependencies

brew update
brew install mysql openssl readline cmake boost zlib
brew link zlib --force

 

4) Getting sources

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 ONLY if ) you want to compile 3.3.5 type:

git checkout 3.3.5

 

Create build folder:

mkdir build
cd build

 

 

5) Generate the XCode project files

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

 

6) Building the binaries

Type the following to build the binaries:

xcodebuild -target install -config Release

 

 

I have tested this tutorial both for branch 3.3.5 and 6.x using a MacBook Pro Retina 15" 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.

5

Share this post


Link to post
Share on other sites

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

2

Share this post


Link to post
Share on other sites

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

 

Edited by Tuxity
0

Share this post


Link to post
Share on other sites

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 :/ Something wrong in the scripts maybe.

 

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

Edited by Tuxity
0

Share this post


Link to post
Share on other sites

It's the same, it's just a symbolic link to avoid the version number in the path.

 

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

 

I used -DSCRIPTS=0 and it's a success :/ Something wrong in the scripts maybe.

 

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).

0

Share this post


Link to post
Share on other sites

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

0

Share this post


Link to post
Share on other sites

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.

Edited by schlumpf
0

Share this post


Link to post
Share on other sites

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.

 

 

 

0

Share this post


Link to post
Share on other sites

Tutorial updated for Mac OS X 10.10.x "Yosemite".

0

Share this post


Link to post
Share on other sites

Tutorial updated for 6.x too.

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

0

Share this post


Link to post
Share on other sites

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:

xcodebuild -target install -config 3.3.5
Is it right? Thanks!
 
 

PS: BRAVOOO

Edited by ikir
0

Share this post


Link to post
Share on other sites

@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 è:

xcodebuild -target install -config Debug

Or:

Oppure:

xcodebuild -target install -config Release

So you can choose to compile in Debug or Release mode

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

0

Share this post


Link to post
Share on other sites

@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!

Edited by ikir
new infos
0

Share this post


Link to post
Share on other sites

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.

Edited by htorbov
0

Share this post


Link to post
Share on other sites

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?

 

 

0

Share this post


Link to post
Share on other sites

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?

 

 

0

Share this post


Link to post
Share on other sites

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?

 

 

0

Share this post


Link to post
Share on other sites

Finally i get TrinityCore 3.3.5 compiled under 10.11 but now i have this issue and world server didn't start at all. Any ides?

 

Using configuration file /Applications/TrinityCore/etc/worldserver.conf.

Using SSL version: OpenSSL 1.0.2d 9 Jul 2015 (library: OpenSSL 1.0.2d 9 Jul 2015)

Using Boost version: 1.59.0

Updating Auth database...

>> Auth database is up-to-date! Containing 1 new and 7 archived updates.

Updating Character database...

>> Character database is up-to-date! Containing 0 new and 4 archived updates.

Updating World database...

>> World database is up-to-date! Containing 102 new and 639 archived updates.

In mysql_stmt_prepare() id: 63, sql: "SELECT spell, item, time, categoryId, categoryEnd FROM character_spell_cooldown WHERE guid = ? AND time > UNIX_TIMESTAMP()"

Unknown column 'categoryId' in 'field list'

In mysql_stmt_prepare() id: 81, sql: "INSERT INTO auctionhouse (id, houseid, itemguid, itemowner, buyoutprice, time, buyguid, lastbid, startbid, deposit) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"

Unknown column 'houseid' in 'field list'

In mysql_stmt_prepare() id: 232, sql: "REPLACE INTO gm_ticket (id, type, playerGuid, name, description, createTime, mapId, posX, posY, posZ, lastModifiedTime, closedBy, assignedTo, comment, response, completed, escalated, viewed, needMoreHelp, resolvedBy) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"

Unknown column 'type' in 'field list'

In mysql_stmt_prepare() id: 236, sql: "UPDATE gm_ticket SET type = 2 WHERE playerGuid = ?"

Unknown column 'type' in 'field list'

In mysql_stmt_prepare() id: 367, sql: "INSERT INTO character_spell_cooldown (guid, spell, item, time, categoryId, categoryEnd) VALUES (?, ?, ?, ?, ?, ?)"

Unknown column 'categoryId' in 'field list'

In mysql_stmt_prepare() id: 426, sql: "INSERT INTO pet_spell_cooldown (guid, spell, time, categoryId, categoryEnd) VALUES (?, ?, ?, ?, ?)"

Unknown column 'categoryId' in 'field list'

In mysql_stmt_prepare() id: 461, sql: "INSERT INTO pvpstats_players (battleground_id, character_guid, winner, score_killing_blows, score_deaths, score_honorable_kills, score_bonus_honor, score_damage_done, score_healing_done, attr_1, attr_2, attr_3, attr_4, attr_5) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"

Unknown column 'winner' in 'field list'

In mysql_stmt_prepare() id: 467, sql: "INSERT INTO battleground_deserters (guid, type, datetime) VALUES (?, ?, NOW())"

Table 'characters.battleground_deserters' doesn't exist

Could not prepare statements of the Character database, see log for details.

Assertion failed: (ec == 0), function unlock, file /BuildRoot/LiAssertion failed: (ec == 0), funbrary/Caches/com.apple.xbs/Sourcction unlock, file /BuildRoot/Lies/libcxx/libcxx-120.1/src/mutexbrary/Caches/com.apple.xbs/Sourc.cpp, line 45.

es/libcxx/libcxx-120.1/src/mutex.cpp, line 45.

Abort trap: 6

0

Share this post


Link to post
Share on other sites
On 1. August 2015 um 13:45:21, ikir said:

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:


xcodebuild -target install -config 3.3.5
Is it right? Thanks!

I have read the answer of Shin to this post, but I don' really understand it. You said:

xcodebuild -target install -config Release

So it is not possible to just build 3.3.5? Which one is built if I use this 'general' command?

 

I had a problem building it the first time, because mysql was in another path. I used -DMYSQL_LIBRARY=/usr/local/lib/libmysqlclient.20.dylib \ and the build succeeded. Was it the correct file? I mean it obviously succeeded, but there was another mysql file in the folder 'libmysqlclient.dylib' which might have been also ok; I just picked the 20 first and wanted to try the other if it fails again...

Edited by chakuze
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.