Compiling Ember On Mac OS X

From WorldForgeWiki
Jump to: navigation, search

Get preprequisites

  1. install xcode 9.2
  2. accept license: sudo xcodebuild -license
  3. install Xcode command line tools: xcode-select --install
  4. install latest macports:

  1. cleanup macports: sudo port uninstall leaves

Additional Notes for 10.7.4 (Lion) and Xcode 4.2+ and MacPorts 2.1.2

  • The original ./ build ember will fail with an error as below. The cause is being investigated, but you can just go into the build directory (x86_64 or whatever uname -i returns), and continue the process by typing "make"
../../../../../../src/framework/float_cast.h:103:3: warning: #warning "Replacing these functions with a standard C cast."
sed: 1: "/Users/sryan/Code/wf/wo ...": bad flag in substitute command: 'l'
make[8]: *** [Ogre.cxx] Error 1
make[7]: *** [all-recursive] Error 1
make[6]: *** [all-recursive] Error 1
make[5]: *** [all-recursive] Error 1
make[4]: *** [all-recursive] Error 1
make[3]: *** [all-recursive] Error 1
make[2]: *** [all-recursive] Error 1
make[1]: *** [all] Error 2
make: *** [all-recursive] Error 1
  • The final linking fails because the SDLMain.o has a main entry point defined, as does the Ember.o (this is not permitted). To correct this, the requires adjustment

Comment out the following piece of the (requires an autogen/ac rerun ... personally I usually just remove the entire x86_64 directory)


if OSX
ember_bin_SOURCES += $(top_srcdir)/src/main/macosx/SDLMain.m
  • The default boost is 1.50 has additional linking requirements ( specifically with boost_chrono-mt and boost_system-mt. In order to change this the macro in acinclude.m4 needs to be modified as below (this will be pushed upstream).
git diff acinclude.m4
diff --git a/acinclude.m4 b/acinclude.m4
index c6cb603..a40e7e1 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -611,9 +611,20 @@ AC_DEFUN([AX_BOOST],
                        AC_CHECK_FILE($BOOST_PATH/lib/lib$, BOOST_THREAD_FULL_PATH=$BOOST_PATH/lib/lib$, 
                                AC_CHECK_FILE($BOOST_PATH/lib64/lib$, BOOST_THREAD_FULL_PATH=$BOOST_PATH/lib64/lib$, BOOST_THREAD_FULL_PAT
-                       AC_MSG_CHECKING(if $BOOST_THREAD_FULL_PATH require extra libs.)
-                       BOOST_EXTRALIBS=`ldd $BOOST_THREAD_FULL_PATH | grep -oE "boost\w*" | sed 's/^/-l/' | tr "\\n" " "`
-                                       AC_MSG_RESULT($BOOST_EXTRALIBS)
+                       AC_MSG_CHECKING(if $BOOST_THREAD_FULL_PATH require extra libs on $build_os)
+                                       case "x$build_os" in
+                                               *darwin*)
+                                                       BOOST_EXTRALIBS="-lboost_chrono-mt -lboost_system-mt"
+                                                       AC_MSG_RESULT(Darwin OSX detected ... hardcoding BOOST_EXTRALIBS: $BOOST_EXTRALIBS)
+                                                       break;
+                                                       ;;
+                                               *)
+                                       BOOST_EXTRALIBS=`ldd $BOOST_THREAD_FULL_PATH | grep -oE "boost\w*" | sed 's/^/-l/' | tr "\\n" " "`
+                                                       AC_MSG_RESULT(Found BOOST_EXTRALIBS : $BOOST_EXTRALIBS)
+                                                       break;
+                                                       ;;
+                                       esac
+                                       dnl AC_MSG_RESULT(BOOST_EXTRALIBS: $BOOST_EXTRALIBS)
                                        BOOST_LDFLAGS="$BOOST_LDFLAGS $BOOST_THREAD_LIB $BOOST_EXTRALIBS"

There are 2 options to correct this:

  1. download and install openal from creative labs for OS X
  2. As the macport issue seems to be a typo, you can change the parameter in the .cpp/.h files to match the appropriate argument name, something like inBufferRef. The correct name is evident by looking at the method source, it is easy to spot.

Using macports from trunk

At the time of writing, the libc++ support is only available in trunk. Official description:

sudo mkdir -p /opt/mports
cd /opt/mports
sudo svn checkout
cd /opt/mports/trunk/base
sudo ./configure --enable-readline
sudo make
sudo make install
sudo make distclean

Now add the following options to macports.conf:

buildfromsource always
cxx_stdlib libc++
configure.cppflags-append "-stdlib=libc++"
configure.cxxflags-append "-stdlib=libc++"
configure.ldflags-append "-stdlib=libc++"

Then update package list with selfupdate.

export PATH=/opt/local/bin:/opt/local/sbin:$PATH
export MANPATH=/opt/local/share/man:$MANPATH
export DISPLAY=:0.0
sudo port -v selfupdate

Get packages

To get some required packages, type:

sudo port install libpng jpeg libxml2 pkgconfig xmlto autoconf automake libtool \
freetype freeimage libzzip boost pcre lua51 curl libsigcxx2 libsdl2 \
wget cmake git mercurial rsync libxdg-basedir makeicns

Now run this script to fix sigc++:

sudo sed -i "" -e '1i\
#ifdef nil \
#undef nil \
#endif \
#define nil none' /opt/local/include/sigc++-2.0/sigc++/functors/functor_trait.h

This patch will create a macro to rename nil to none. WARNING: It will ABI break every library, which uses sigc++. You will need to rebuild them! If you have only installed the packages listed above, then nothing needs to be rebuilt.

cmake will fail bundling the app libs, if it can't change the files after copying it, so execute: sudo chmod +w /opt/local/lib/*.dylib

Get Hammer

To get hammer type:

git clone
cd hammer

Install dependencies

To install some packages (tolua++, freealut, cegui, ogre) not available in macports:

./ install-deps all

Getting the source

Next we will download all the sources for the Worldforge projects and all needed libraries. Execute this command to begin:

./ checkout libs
./ checkout ember


First, you need to create a symlink for libtoolize.

ln -s -f "/opt/local/bin/glibtoolize" "work/local/bin/libtoolize"

Now we are ready to build! Just execute this command:

./ build libs
./ build ember


After creating the app, you can start ember by double clicking on or from the terminal:

open work/local/bin/