[HOWTO] MacOS X Compilation Guide

25 replies [Last post]
Koda
Koda's picture
User offline. Last seen 2 days 2 hours ago. Offline
Joined: 2008-11-10
Posts: 215

NOTE: this information is likely to be outdated! Please refer to http://code.google.com/p/hedgewars/wiki/BuildingOnMac for the newest version

Girder Girder

Hi all!
I believe that Hedgewars is really a neat game and i'm sure it will increasly become more popular with such development pace.

I really like the development choices like QT4 and cmake because with them it's really easy to port to several archs.
In fact the linux and windows builds are there and work fine! What about MacOSX?

i've seen many others in the forums asking this question and so i started looking at the problem, making up my mind that i had to find it!

It was a long night, but completely worth it Smile
The problem is at the linking stage for the final hwengine executable! the freepasacal compiler seems to forget every library path that was configured; so with a small modification we finally get the mac executable!

[*update* 04/24/2009] compilation guide has been MUCH simplified; no more hours for compiling, just a couple of libraries to install! The original is still available in my blog

[*update* 07/02/2009] finally when you install the bundle is relocatable but won't work on other computers! If you wish to do so you need to specify -DBUNDLE=1 at cmake step and install the macdeployqt utility as well as the Glasgow Haskell Compiler with DataEnc, utf8 and (a third one i don't remember right now) from the cabal utility (read: create a bundle only if you know what you are doing).

[*update* 04/27/2010] did anyone read this guide? it took one year+ to notice that i was missing the freepascal step xD

GirderGirderGirderGirderGirder

LET'S START

  1. download and install MacPorts from www.macports.org to the default install dir (also Fink from here works).

  2. from a Terminal, install cmake

    Quote:
    sudo port install cmake

  3. download the whole SDL suit, and put the frameworks in /Library/Frameworks

  4. unpack the Ogg and Vorbis frameworks from this installer (might be a little outdated)

  5. install the QT SDK using their installer from here

  6. install Freepascal (>2.2) from here

  7. unpack the hedgewars source and run this command

    Quote:
    cmake ../hedgewars-source-DQT_QMAKE_EXECUTABLE=/usr/bin/qmake -DCMAKE_BUILD_TYPE=Release

  8. run make and make install

  9. PLAY!!! just open the folder and double click the bundle! You can move it wherever you want

GirderGirderGirderGirderGirder

All the separate installers can also be downloaded from macports or fink, just like you did with cmake at first step.

bye
Koda

revisions
*27/04/10* added the freepascal step and fink option
*24/01/09* updated with some error correction
*24/04/09* updated to reflect development changes
*26/04/09* updated for automatic bundle creation
*02/07/09* updated for optional relocatable bundle creation

Josh
Josh's picture
User offline. Last seen 9 years 17 weeks ago. Offline
Joined: 2008-11-09
Posts: 430

Let me be the first to congratulate and thank you for successfully making a OSX build! Big Grin

daimadoshi85
daimadoshi85's picture
User offline. Last seen 7 years 36 weeks ago. Offline
Joined: 2008-05-04
Posts: 372

YOU'RE THE BEST!So it's possible now to create a build that anyone can download from the site?Anyone can do it?

Come to the dark side, we have cookies... - V

Hedgewars script for ubuntu is here...but maybe I have to update it first Smile

GrepACE
User offline. Last seen 9 years 43 weeks ago. Offline
Joined: 2009-01-14
Posts: 3

Koda,

Is this your page?

http://projectsymphony.blogspot.com/2009/01/hedgewars-finally-compile-on-mac-os-x.html

Your post matches it exactly (or vice versa).

How can you make this compile portable? I am getting library dependency issues on Macs
other than my dev machine.

dyld: Library not loaded: /opt/local/libexec/qt4-mac/lib/QtSvg.framework/Versions/4/QtSvg
Referenced from: /Applications/Hedgewars 0.9.8/bin/hedgewars
Reason: image not found
Trace/BPT trap

Koda
Koda's picture
User offline. Last seen 2 days 2 hours ago. Offline
Joined: 2008-11-10
Posts: 215

you mean something like this?

8-)
just give it some testing and i'll release it
thanks to Tiy for the icon

bye
Koda
ps: yes that's my often abandoned blog Smile

Koda
Koda's picture
User offline. Last seen 2 days 2 hours ago. Offline
Joined: 2008-11-10
Posts: 215

since you asked for it...

http://www.hedgewars.org/node/1140

Wink Smiley

Josh
Josh's picture
User offline. Last seen 9 years 17 weeks ago. Offline
Joined: 2008-11-09
Posts: 430

Koda allegedly wrote:
since you asked for it...

http://www.hedgewars.org/node/1140


We need it for 0.9.9 now... Wink Smiley

GrepACE
User offline. Last seen 9 years 43 weeks ago. Offline
Joined: 2009-01-14
Posts: 3

Koda,

Is there any chance that you could post exactly how you got this thing to compile properly? I could never get a compiled version that would work on anything other than the machine that I compiled it on. Your instructions above do not accomplish this. I compiled Qt statically and the SDL components as well, but still no luck. I am really curious as to how you did this. I would like to work in the Glasgow Haskell Compiler and get the server component working on OS X Leopard as well.

Thanks for all of your hard work!

Koda
Koda's picture
User offline. Last seen 2 days 2 hours ago. Offline
Joined: 2008-11-10
Posts: 215

Josh allegedly wrote:
Koda allegedly wrote:
since you asked for it...

http://www.hedgewars.org/node/1140


We need it for 0.9.9 now... ;)

i've posted it at the same place Smile http://www.hedgewars.org/node/1140

GrepACE allegedly wrote:
Koda,

Is there any chance that you could post exactly how you got this thing to compile properly? I could never get a compiled version that would work on anything other than the machine that I compiled it on. Your instructions above do not accomplish this. I compiled Qt statically and the SDL components as well, but still no luck. I am really curious as to how you did this. I would like to work in the Glasgow Haskell Compiler and get the server component working on OS X Leopard as well.

Thanks for all of your hard work!

yes the instruction here generate an executable that works only on the machine it's compiled on!
In order to compile them statically you have to do some not-so-easy steps:
- completely remove the shared version of libsdl (because cmake always preferes shared over static)
- manually insert all the libs and frameworks qt and sdl depend on
- modify SDLh.pas and change every *.dylib reference into a *.a

so it's rather complicated, it took me a week to figure how to resolve this
if you need assistance i'm often in the irc channel so you can come and ask me Smile

i've heard that the haskell server has some problems on some other oses as well so i wouldn't worry too much (even though i'd love to have it working)

bye
Koda

Koda
Koda's picture
User offline. Last seen 2 days 2 hours ago. Offline
Joined: 2008-11-10
Posts: 215

hi!
i've submitted a patch so next version (0.9.10) should much more easier to compile
that version also solves some bugs of the previous builds Smile

among other news there's also a HEAD build available
http://dl.getdropbox.com/u/24468/hedge-mac-head.tar.bz2

Smile))

enjoy

Koda

Koda
Koda's picture
User offline. Last seen 2 days 2 hours ago. Offline
Joined: 2008-11-10
Posts: 215

I updated the guide to show the lastest developments in the source code
Hedgewars for Mac now properly uses standard Mac frameworks instead of Unix libraries; this mean less time to compile, more platform support and better integration.

Koda

saffire
User offline. Last seen 9 years 16 weeks ago. Offline
Joined: 2009-05-12
Posts: 1

Thanks Koda,

it worked for my local Mac, but if I want to distribute the compiled application, it doesn't work.

How do I excactly build hedgewars for distribution on Mac OS X ?

Thanks.

Koda
Koda's picture
User offline. Last seen 2 days 2 hours ago. Offline
Joined: 2008-11-10
Posts: 215

update for creating relocatable bundles

nicolunacba
User offline. Last seen 8 years 15 weeks ago. Offline
Joined: 2009-08-15
Posts: 2

Hello! I installed GHC, made cmake like

cmake . -DQT_QMAKE_EXECUTABLE=/usr/bin/qmake -DCMAKE_BUILD_TYPE=Release -DBUNDLE=1
-- Found OggVorbis: /opt/local/lib/libvorbisfile.dylib;/opt/local/lib/libvorbis.dylib;/opt/local/lib/libogg.dylib
-- Found Sparkle: /Users/macbook/Library/Frameworks/Sparkle.framework
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/macbook/Downloads/hedgewars-scm-2009-08-16

and I get this during make:

Utils.hs:18:17:
Could not find module `Codec.Binary.UTF8.String':

I think that it's included in GHC, but why? What can I do? Sorry if this is not the correct place to post.

Smaxx
Smaxx's picture
User offline. Last seen 7 years 27 weeks ago. Offline
Joined: 2009-04-29
Posts: 391

If you don't need the server executable (you intend to play over the official server) you might be able to ignore it.

Right now I'm not sure if Cmake will build the other files. If it doesn't, try to open "\gameServer\CMakeLists.txt" and remove its contents (make a backup copy first). Then build again.

If you really want the server, you'll have to install that module first (can be found here).

nicolunacba
User offline. Last seen 8 years 15 weeks ago. Offline
Joined: 2009-08-15
Posts: 2

At the start of compiling, I get this error:
/Users/macbook/Downloads/hedgewars/trunk/openalbridge/openalbridge.c: In function ‘openal_init’:
/Users/macbook/Downloads/hedgewars/trunk/openalbridge/openalbridge.c:75: error: nested functions are disabled, use -fnested-functions to re-enable
/Users/macbook/Downloads/hedgewars/trunk/openalbridge/openalbridge.c:75: error: syntax error before ‘*’ token
/Users/macbook/Downloads/hedgewars/trunk/openalbridge/openalbridge.c:89: error: ‘default_device’ undeclared (first use in this function)
/Users/macbook/Downloads/hedgewars/trunk/openalbridge/openalbridge.c:89: error: (Each undeclared identifier is reported only once
/Users/macbook/Downloads/hedgewars/trunk/openalbridge/openalbridge.c:89: error: for each function it appears in.)
make[2]: *** [openalbridge/CMakeFiles/openalbridge.dir/openalbridge.c.o] Error 1
make[1]: *** [openalbridge/CMakeFiles/openalbridge.dir/all] Error 2
make: *** [all] Error 2

I modified the CMake file to use the flag -fnested-functions, and it fails too. Why? I made

aquamarine:trunk nico$ cmake . -DQT_QMAKE_EXECUTABLE=/usr/bin/qmake -DCMAKE_BUILD_TYPE=Release -DBUNDLE=1
-- Found OggVorbis: /usr/local/lib/libvorbisfile.dylib;/usr/local/lib/libvorbis.dylib;/usr/lib/libogg.dylib
-- Looking for QT_MAC_USE_COCOA
-- Looking for QT_MAC_USE_COCOA - not found.
-- Found Qt-Version 4.5.2
-- Found Sparkle: /Users/macbook/Library/Frameworks/Sparkle.framework
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/macbook/Downloads/hedgewars/trunk

What's happenning T_T?

Koda
Koda's picture
User offline. Last seen 2 days 2 hours ago. Offline
Joined: 2008-11-10
Posts: 215

nicolunacba allegedly wrote:

Hello! I installed GHC, made cmake like

cmake . -DQT_QMAKE_EXECUTABLE=/usr/bin/qmake -DCMAKE_BUILD_TYPE=Release -DBUNDLE=1
-- Found OggVorbis: /opt/local/lib/libvorbisfile.dylib;/opt/local/lib/libvorbis.dylib;/opt/local/lib/libogg.dylib
-- Found Sparkle: /Users/macbook/Library/Frameworks/Sparkle.framework
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/macbook/Downloads/hedgewars-scm-2009-08-16

and I get this during make:

Utils.hs:18:17:
Could not find module `Codec.Binary.UTF8.String':

I think that it's included in GHC, but why? What can I do? Sorry if this is not the correct place to post.


Hi,
you need to download the following packages with cabal:
dataenc, hslogger, utf8-string
or use the binary installer from the ghc site (which already contains them)

nicolunacba allegedly wrote:

At the start of compiling, I get this error:
/Users/macbook/Downloads/hedgewars/trunk/openalbridge/openalbridge.c: In function ‘openal_init’:

[long sequence of errors]

-- Generating done
-- Build files have been written to: /Users/macbook/Downloads/hedgewars/trunk

What's happenning T_T?

Hello,
i can't reproduce and the only difference is that I'm using QT 4.4.3 (which i don't really believe might be the cause)

could you try if latests commit fixed the problem for you?
bye
Koda

Arth
Arth's picture
User offline. Last seen 8 years 4 days ago. Offline
Joined: 2009-10-25
Posts: 3

Hi! Please, help!

error: #error "You are building a 64-bit application, but using a 32-bit version of Qt. Check your build configuration."

What flag I need add to "cmake ../hedgewars-src-0.9.8 -DQT_QMAKE_EXECUTABLE=/usr/bin/qmake -DCMAKE_BUILD_TYPE=Release -DBUNDLE=1"??

Smaxx
Smaxx's picture
User offline. Last seen 7 years 27 weeks ago. Offline
Joined: 2009-04-29
Posts: 391

I assume you'll have to compile a 64 bit version of Qt first.

Arth
Arth's picture
User offline. Last seen 8 years 4 days ago. Offline
Joined: 2009-10-25
Posts: 3

Smaxx allegedly wrote:

I assume you'll have to compile a 64 bit version of Qt first.

Thanks, but I have 32 bit system! I don't know, how I can compile 32 bit version Hedgewars.

Smaxx
Smaxx's picture
User offline. Last seen 7 years 27 weeks ago. Offline
Joined: 2009-04-29
Posts: 391

Odd, should compile as 32 bit by default then.

Kg. Madee II.
Kg. Madee II.'s picture
User offline. Last seen 6 years 10 weeks ago. Offline
Joined: 2009-11-09
Posts: 1

Any progress with PPC support?
I'd gladly try out any new versions…

nemo
nemo's picture
User offline. Last seen 1 day 16 hours ago. Offline
Joined: 2009-01-28
Posts: 1648

PPC is now functional in HEAD thanks to koda

--
Oh, what the heck. 1PLXzL1CBUD1kdEWqMrwNUfGrGiirV1WpH <= tip a hedgewars dev

Koda
Koda's picture
User offline. Last seen 2 days 2 hours ago. Offline
Joined: 2008-11-10
Posts: 215

updated some missing steps/dependencies (reported by Henek) and added some warnings when creating a bundle

Cairo
Cairo's picture
User offline. Last seen 11 weeks 4 days ago. Offline
Joined: 2010-07-06
Posts: 198

Thanks!

Style is spelled style not stile.
Use Dropbox to backup your important goodies!

Koda
Koda's picture
User offline. Last seen 2 days 2 hours ago. Offline
Joined: 2008-11-10
Posts: 215

this topic is officially outdated!
Check out the newest wiki on http://code.google.com/p/hedgewars/wiki/BuildingOnMac

Copyright © 2004-2017 Hedgewars Project. All rights reserved. [ contact ]