Mac Compile Troubleshooting - secure411dotorg/mal4s GitHub Wiki


####Error about SDL2

Get the sdl2 "bottle" here, noticing what directory you save it to.

Let's say it winds up in your Downloads directory:

brew install ~/Downloads/sdl2-2.0.1.mavericks.bottle.tar.gz

A successful brew shows a glass of beer at the end. Now you can continue with a regular build of mal4s such as brew -v install mal4s


####Pre-Mavericks

Advanced users may succeed with versions of Mac OS older than Mavericks but if you want it to be easy and definitely work, have Mavericks. We did compile on older versions in the past but haven't tried with recent versions of Mal4s due to a variety of challenges.

####OSX Mavericks After installing Maverick, you need to update xcode via the app store. After updating xcode, the command line tools need to be installed again, which currently is missing from the GUI, so you can install them by typing xcode-select --install at the terminal.

Any dependency for the build that was compiled before the update to Maverick may need to be rebuilt. This can be done by typing brew remove --force FORMULA and then brew install --fresh FORMULA, such as brew remove --force gmp4 and brew install --fresh gmp4. Then you can try again on the formula that failed to brew, in our case gcc48. Note, you are trying to fix an incompatibility between libc++ and libstdc++. Maverick uses libc++ as the default while Moutain Lion uses libstdc++. Read the failure carefully as you will need to determine which dependency is using libstdc++ and recompile that. Note that libc++/libstdc++ are so similar to a human reading it that we can get it backwards very easily.

#####If you get an error about pcre or libstdc++

######I got this error:

Error: mal4s dependency pcre was built with the following
C++ standard library: libstdc++ (from gcc)
 
This is incompatible with the standard library being used
to build mal4s: libc++ (from clang)
 
Please reinstall pcre using a compatible compiler.

######I had success just by doing this:

brew remove --force pcre
Uninstalling pcre...

brew install --fresh pare

(snip, lots of installing stuff shows here)

brew install mal4s

####Removing all dependencies and starting over If there were old versions of the dependencies for Mal4s still hanging around, it could cause the build to fail. So this is how we can remove all the dependencies and start over.

#brew remove to remove the installed packages.  Brew will not remove anything that is not in the Cellar
brew remove --force autoconf automake boost cloog018 ecj freetype gcc48 glew glm gmp4 isl011 jpeg \
libmpc08 libpng libtool mpfr2 pcre pkg-config sdl sdl_image sdl_mixer mal4s

#The packages are also in the cache
cd /Library/Caches/Homebrew/
rm -rf autoconf* automake* boost* cloog018* ecj* freetype* gcc48* glew* glm* gmp4* isl011* jpeg* \
libmpc08* libpng* libtool* mpfr2* pcre* pkg-config* sdl* mal4s*

You should now be able to try again with the compiling instructions for Mac.

####Using gcc-4.8 for some cases

We did not need this for Mavericks but it is possible it may be needed for some other OS versions, depending on if the C++11 code is supported by your compiler or not.

This will install gcc 4.8:

brew tap homebrew/versions
brew install gcc48 --enable-all-languages #Should take a while

There are a few dependencies for mal4s that do not build well with --cc=gcc-4.8 so we must build them first. boost may break the build if installed as a bottle, so we may need to build boost before using the Formula for mal4s.

brew install boost --HEAD --cc=gcc-4.8

brew install --cc=gcc-4.8 mal4s

The above is not well tested because I upgraded to Mavericks after successfully compiling using gcc-4.8 on a lesser Mac OS / xcode version. I believe I also set the compiler to gcc-4.8 in the def install section of the brew formula the time that I successfully compiled with gcc-4.8.