Saturday, April 10, 2010

wxWidgets on OSX

wxWidgets is one of the worst toolkits known to man. Unfortunately, people keep using it, so I need to keep compiling it. I personally prefer FLTK, my only complaint about FLTK is that it can look pretty poor. Recently I have been looking around for a very light-weight native cross platform widget toolkit - no luck so far. (Suggestions anyone?)

Here are some instructions on compling wxWidgets (ex wxWindows) for Apple Mac OSX Snow Leopard. To begin, download wxMac, decompress it, open a terminal and navigate to the base wxMac directory.
mkdir osx_build
cd osx_build
You will most probably want to have OpenGL support with wxWidgets, so remember the "--with-opengl" flag. As with most projects, the 64bit support on OSX is flaky, so it is best to compile for 32bit using "-arch i386". Hopefully this won't be necessary in the near future.
../configure --with-opengl CFLAGS="-arch i386" CXXFLAGS="-arch i386" CPPFLAGS="-arch i386" LDFLAGS="-arch i386" OBJCFLAGS="-arch i386" OBJCXXFLAGS="-arch i386" 
(Note: other handy options are: --with-cocoa, --disable-shared --enable-static, --enable-unicode, --enable-debug. At present Cocoa support is dubious, again, this may change in future.)

(you may wish to confirm that opengl canvas is enabled - see:
/usr/lib/wx/include/mac-unicode-debug-2.8/wx/setup.h)
make
You should have a lib directory with all the dylib's in it.
Unfortunately, for wx to work, you will need to install it.
sudo make install

make samples
This should generate a whole bunch of samples in the osx_build/samples directory

Now you can run the samples! (Note: the samples can not be run from the command line, you need to run the applications, otherwise the program will not gain focus and you won't be able to click on any of the buttons!)

No comments: