HOWTO: Compile Gnaural on MacOSX

From Gnaural Wiki
Jump to: navigation, search

Building Gnaural on MacOSX

Building Gnaural on MacOSX is a three step process. First you must install Apple's XCode developer tools so you can compile stuff generally, then you need to build the GTK+ and various other independent libraries that Gnaural relies on for its portability, then finally you can build Gnaural.

In terms of XCode, I use ver 3.14 (xcode314_2809_developerdvd.dmg), since ver 2.5 (xcode25_8m2558_developerdvd.dmg) now seems to require something later anyway in order to be selectable. Be sure to select "UNIX Development Support" during the installation process. Once it is installed, you might still need to add some paths to make tit possible to use a different compiler if desired, etc., as detailed HERE. For example, to use 2.5 instead of 3.14, i just pico ~/.bash_profile and add this to it:

export PATH="$PATH:/Users/[username]/.local/bin"
export DEVELOPER_DIR="/Xcode2.5"
sudo xcode-select -switch /Xcode2.5
export PATH=${DEVELOPER_DIR}/usr/bin:${PATH}
export MANPATH=${DEVELOPER_DIR}/usr/share/man:${MANPATH}


First build the miscellaneous libs Gnaural relies on: 1) To build the GTK+ libs, go here: http://sourceforge.net/apps/trac/gtk-osx/wiki/Build That has very detailed instructions, but for my own streamlined use, i've reduced it to these steps. First download this: http://downloads.sourceforge.net/sourceforge/gtk-osx/gtk-osx-build-setup.sh then run it (i had to change it to executable, btw, chmod uog+x). This installs jhbuild down in ~/.local/bin/jhbuild shell You will want to add that directory to the path, btw; here is how i did it:

pico ~/.bash_profile

Then paste this on a newline in there:

export PATH="$PATH:/Users/[username]/.local/bin"

2) Pasting this in a terminal shell will build all the GTK+ libs. Know that it takes at least 30 minutes:

jhbuild shell
export PATH=$PREFIX/bin:$PATH
cd ~
jhbuild bootstrap
jhbuild build meta-gtk-osx-bootstrap
jhbuild build meta-gtk-osx-core
jhbuild build
jhbuild build meta-gtk-osx-themes
jhbuild buildone libglade

3) Download the bundler from here:

http://downloads.sourceforge.net/sourceforge/gtk-osx/ige-mac-bundler-0.5.3.tar.gz

then paste SOMETHING like this (Safari, trying to be helpful, unzips the filename as you download it, so you may need to vary line 3 and 4 to use "ige-mac-bundler-0.5.3.tar"):

mkdir ~/src
mv ~/Downloads/ige-mac-bundler-0.5.3.tar.gz ~/src
cd ~/src
tar zxvf ige-mac-bundler-0.5.3.tar.gz
cd ige-mac-bundler-0.5.3
make install

4) libsndfile will need FLAC, OGG, Vorbis, so download their source code from here:

http://xiph.org/downloads/

All worked with the exact steps as used for portaudio and libsndfile, EXCEPT flac, which needed me to turn-off assembly optimizations by using this instead of the ususal:

./configure --prefix ~/gtk/inst --libdir '${exec_prefix}/lib'  --disable-static --disable-gtk-doc --disable-docs --disable-scrollkeeper --without-emacs --disable-java --disable-native-java --disable-libasprintf --disable-csharp -disable-asm-optimizations --with-lib-preference=local,system
make 
make install

5) Now download the all important portaudio and libsndfile source code from:

portaudio and libsndfile

Decompress them in to ~/src, then go in to each of their directories and paste the following:

./configure --prefix ~/gtk/inst --libdir '${exec_prefix}/lib'  --disable-static --disable-gtk-doc --disable-docs --disable-scrollkeeper --without-emacs --disable-java --disable-native-java --disable-libasprintf --disable-csharp
make 
make install

Now you are done building the supporting libraries and can build Gnaural:

1) While still in the terminal using jhbuild shell as used for the above steps, paste this:

cd ~/src
cvs -z3 -d:pserver:anonymous@gnaural.cvs.sourceforge.net:/cvsroot/gnaural co -P gnaural
cd ~/src/gnaural
./configure --prefix ~/gtk/inst --libdir '${exec_prefix}/lib'  --disable-static --disable-gtk-doc --disable-docs --disable-scrollkeeper --without-emacs --disable-java --disable-native-java --disable-libasprintf --disable-csharp
make clean
make
make install

2) Now bundle it.

unzip ~/src/gnaural/misc/gnaural_MacOSX-bundler.zip
cd ~/src/gnaural/gnaural_MacOSX-bundler
ige-mac-bundler gnaural.bundle
cp ~/Desktop/Gnaural.app/Contents/Resources/share/gnaural/gnaural.glade ~/Desktop/Gnaural.app/Contents/MacOS/

That'll put a brand spanking new "Gnaural.app" file on your desktop - and if you aren't going to share this with other Mac users, you are truly all done! BUT if you want to make this a portable bundle, you must deal with the fact that while this bundle works on your Mac, it won't run on others because Mac uses absolute paths embedded in both libraries and executables you just built. To solve this problem turned out to be the hardest part of porting Gnaural to Mac, but i have a solution:

3) Use my hack to "relink" all the lib paths in your Gnaural Bundle. Make sure the Gnaural.app bundle is on your Desktop (it has to be for my hack to work), then cd in to the "misc/" directory in the gnaural source code and run the hack - if you are just continuing from step 2), it is as simple as pasting this:

~/src/gnaural/misc/ChangeInternalPaths.sh

To be sure really it's only accessing the relevant homemade libs, move the GTK+ directory temporarily:

mv ~/gtk ~/gtkBAK

the this to return it after sufficiently satisfied it works:

mv ~/gtkBAK ~/gtk


4) If you want to share this app with other people, just right-click on it and use Mac's internal compress feature available in the menu that comes up. You could do it using the DMG approach using "Disk Utility", but i have found no advantages yet to that approach.

EXTRA NOTES:

0) here's the core Gnaural parts in a tidy paste for those times when i'm testing code changes:

mv ~/gtkBAK ~/gtk
cd ~/src/gnaural
./configure --prefix ~/gtk/inst --libdir '${exec_prefix}/lib'  --disable-static --disable-gtk-doc --disable-docs --disable-scrollkeeper --without-emacs --disable-java --disable-native-java --disable-libasprintf --disable-csharp
make clean
make
make install
cd ~/src/gnaural/gnaural_MacOSX-bundler
rm -R ~/Desktop/Gnaural.app
ige-mac-bundler gnaural.bundle
cp ~/Desktop/Gnaural.app/Contents/Resources/share/gnaural/gnaural.glade ~/Desktop/Gnaural.app/Contents/MacOS/
~/src/gnaural/misc/ChangeInternalPaths.sh
mv ~/gtk ~/gtkBAK
cd ~/Desktop/Gnaural.app/Contents/MacOS/
sh Gnaural

1) your best friend in this whole process is:

otool -L [executable/library name]

This will tell you EXACTLY what it's dependencies are, and can save you hours of time trying to figure out why something isn't working.

2) To make an icns file, download pic2icon and run a 512x512 scaled Gnaural icon through it. Then run it through "Icon Composer", found down in "/Developer/Applications/Utilities/Icon Composer.app" - I got all this from here:

http://macapper.com/2007/04/21/how-to-create-custom-icons-for-your-mac/

(20100424)

3) To make a .dmg (mountable downloaded bundle), run Disk Utility.app