torsdag 23 april 2009

How to install the wxWidgets library in Mac OS X Leopard

wxWidgets is a cross-platform toolkit for developing programs using only one codebase. Most important of all before talking about its features; it's open source and free both for commercial and non-commercial usage.

wxWidgets has support for Win32, Mac OS X, GTK+, X11 and more. You can do many kinds of things with wxWidgets: Graphical User Interfaces, sockets, multithreading, loading images, connecting to databases and much more. It also has bindings for many different programming languages, but I will only focus on C++ here.

Ok, it has got all those fancy features. But why choose wxWidgets and not any of the other various toolkits which are available? Well, first of all it's open source and free, which I mentioned above. Secondly, it makes use of native controls in the different platforms instead of emulating them, which I personally find quite nice. No ugly emulated controls, which many other toolkits use.

These things together with good online documentation and an active forum makes the decision about which toolkit to use quite easy for me. Of course it depends on what I'm developing, but for many of the tasks wxWidgets is very usable.

There is also a book available, written by one of the original creators of wxWidgets. I can recommend the book, there is very much usable information in it. It's actually available for free download online as a pdf, since it's part of Bruce Peren's Open Source Series. But having the book in paper form can be really handy when you're coding.


Installing wxWidgets in Mac OS X Leopard
I've only tried installing wxWidgets in OS X 10.5 since it's what I'm using. But according to the documentation, wxWidgets should work in OS X 10.3 and above.

  1. To be able to compile and install wxWidgets you have to have Apple Developer Tools installed on your system. It can be found either on one of the CDs which came with your Mac, or downloaded from Apple Developer Connection (requires a free registration).

  2. After installing Apple Developer Tools you're ready to download the wxWidgets source archive, wxMac. Do this from the official download site.

  3. Unzip the source archive and change directory into the wxWidgets directory.

  4. Run the following commands:
    $ mkdir macbuild
    $ cd macbuild

    $ ../configure
    $ make

  5. The wxWidgets library should now be compiled and ready to be installed. Run
    $ sudo make install

    To install wxWidgets on you
    r system. If everything is OK, you can now start developing your own programs using wxWidgets.

  6. (optional) Compile a test program and run it to make sure everything is working.

    $ cd samples/minimal

    $ make
    $ open minimal.app

    If a window like the one above starts then you have succeded. Now you really can start developing your own programs.

This was all. You have now installed wxWidgets system-wide as a dynamically linked library. Happy coding!

Recommended reading
General tutorials and guides: wxWiki
wxWidgets FAQ for Mac: Mac FAQ
Especially the last part about "Why can't I set focus to my wxMac application?" can be interesting.

onsdag 22 april 2009

The attack of the ants

What happens when ants discover foreign things in their anthill? They try to kill the foreign scary thing of course! My remote had a weird smell of formic acid for the rest of the day...

This is actually just a test of uploading pictures.

But anyways. The story is true. I don't know why I did it.