Tuesday 13 January 2009

HEDGEWARS finally compiles on Mac OS X

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 :)
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!


LETS START

1 - download and install MacPorts from www.macports.org to the default install dir

2 - from a Terminal, install all the necessary software

sudo port install qt4-mac libsdl libsdl_mixer libsdl_image libsdl_ttf libsdl_net cmake

it is a rather long procedure, manly due to qt framework; if you're an impatient guy there are some builds around (like these)


i also installed SDL (and all its friends) from the SDL homepage (http://www.libsdl.org/) just to be on the safe side... i don't know whether they're compulsory or not

3 - unpack the hedgewars source and run this command

cmake ../hedgewars-src-0.9.8 -DCMAKE_CXX_FLAGS="-O2" -DQT_QMAKE_EXECUTABLE=/opt/local/bin/qmake-mac -Wno-dev -DCMAKE_BUILD_TYPE=Release

if you like, you can change the default install location by setting -DCMAKE_INSTALL_PREFIX and -DDATA_INSTALL_DIR

4 - before running make, you have to modify the following file: CMakeFiles/hwengine.dir/build.make, so open it and find the line that invokes the freepascal compiler

mine was like this
/usr/local/bin/fpc -B -FE../bin -Cs2000000 -vwi -O2 /(path-to-sources)/hedgewars-src-0.9.8/hedgewars/hwengine.dpr

you just have to add -Fl/opt/local/lib at the end, like
/usr/local/bin/fpc -B -FE../bin -Cs2000000 -vwi -O2 /(path-to-sources)/hedgewars-src-0.9.8/hedgewars/hwengine.dpr -Fl/opt/local/lib

5 - run make and sudo make install

6 - PLAY!!! just open terminal and write hedgewars


it's rather long for an install procedure but it really works :)
right now i'm working on the bundle archive, but i believe it'll take from me more than i thought

i hope that someone can find it useful :)
(and that the dev correct the workaround at 4)

Vitto

3 comments:

  1. I am almost there on compiling this on Leopard, but I am getting this error:

    Assembling hwengine
    Linking ../bin/hwengine
    ld: library not found for -lgcc
    An error occurred while linking
    Error: Error while linking
    Fatal: There were 1 errors compiling module, stopping
    Fatal: Compilation aborted
    Error: /usr/local/bin/ppc386 returned an error exitcode (normal if you did not specify a source file to be compiled)
    make[2]: *** [bin/hwengine] Error 1
    make[1]: *** [hedgewars/CMakeFiles/hwengine.dir/all] Error 2
    make: *** [all] Error 2

    Any ideas/suggestions?

    Here's what the system reports on the gcc lib:

    sh-3.2# locate libgcc
    /usr/lib/libgcc_s.1.0.dylib
    /usr/lib/libgcc_s.1.dylib
    /usr/lib/libgcc_s_ppc64.1.dylib
    /usr/lib/libgcc_s_x86_64.1.dylib

    sh-3.2# gcc --print-libgcc-file-name
    /usr/lib/gcc/i686-apple-darwin9/4.0.1/libgcc.a

    ReplyDelete
  2. I finally got it to compile. I had to add another -Fl option that pointed to the libgcc.a location.

    I went from this:

    usr/local/bin/fpc -B -FE../bin -Cs2000000 -vwi -O2 /Users/petedodd/Desktop/hedgewars-src-0.9.8/hedgewars/hwengine.dpr -Fl/opt/local/lib

    To this:

    usr/local/bin/fpc -B -FE../bin -Cs2000000 -vwi -O2 /Users/petedodd/Desktop/hedgewars-src-0.9.8/hedgewars/hwengine.dpr -Fl/usr/lib/gcc/i686-apple-darwin9/4.0.1 -Fl/opt/local/lib

    Then it compiled. Thanks for your post on this. Very helpful!

    ReplyDelete
  3. Wow. What great timing. I just discovered this game. Any chance on getting a nice simple file I can just install or drag and drop into my Applications?

    ReplyDelete



All the projects here are under a Creative Commons 3.0 licence! You can use and distribute them as you like (just quote the author so he knows his work is not useless)!

If you wish to get in touch with me write at projectsymphony@gmail.com