Compiling, installing and using AntTweakBar on Mac OS X

Alec Jacobson

August 30, 2010

weblog/

Seeing Bruno Levy's demos at SIGGRAPH 2010 convinced me that I want to start using the painlessly easy prototyping GUI library, AntTweakBar. The premise of AntTweakBar is great. Prototyping should be easy and a researcher shouldn't spend any time on UI that just flips flags and changes input parameter values. With AntTweakBar UI is added with a single line of code for any variable you want to expose. Moreover AntTweakBar figures out which type of UI element should show up: switches for bools, RGB/HSV value manipulators for colors, spinners for numbers. And it's all Glut and OpenGL (and DirectX I guess), which for most is exactly what they're already using. Compiling and installing AntTweakBar as a dynamically linked library on a mac is a bit tricky though. Here's what I did: Dowload the source from the AntTweakBar site. Go to the source directory:
cd AntTweakBar/src
I had to make some changes to the Makefile.osx. Edit the lines to look like this
CXXCFG          = -O3 -arch i386 -arch x86_64
LFLAGS          = -arch i386 -arch x86_64
OUT_DIR         = /usr/local/lib

BASE            = /Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks
I want to compile AntTweakBar universally (32-bit and 64-bit) for a 10.6 machine so I need those -arch options. You can leave those out if you just want the default setting. Copy Makefile.osx over the exisiting Makefile:
cp Makefile.osx Makefile
Then build with
sudo make
This will put the dylib in the right place so you don't have to mess with DYLD_LIBRARY_PATH each time you link to AntTweakBar Since I've installed libAntTweakBar.dylib all the way at the /usr/local/ level, I'll also put the header file there:
sudo cp ../include/AntTweakBar.h /usr/local/include
Now, hop over to the examples directory:
cd ../examples
Now you should be able to universally compile a simple example with the following:
gcc -O3 -arch i386 -arch x86_64 -Wall -fno-strict-aliasing -D_MACOSX TwSimpleGLUT.c -lAntTweakBar -lpthread -lm -framework OpenGL -framework GLUT -o TwSimpleGLUT
And run it with:
./TwSimpleGLUT
And you should get something like this: anttweakbar simple example screen capture Update: Mac ports does have a port for AntTweakBar, but it's always such a nightmare dealing with the 32-bit/64-bit problem with mac ports so I have done the above. With macports you can just issue:
sudo port install anttweakbar
And you should be able to compile and run the example in the same manner.