Friday, September 21, 2007

Installing wxWidgets under Apple OS-X

wxWidgets (formerly known as wxWindows) is a very, very useful cross platform GUI development library. In plain English, you can write an application once on any platform, then deploy it easily on a completely different platform. It's Java Swing without the processing overhead!

You'll find that the installation of wxWidgets on an OS-X system is quite straight-forward but the documentation can confuse the newcomer a little. This may help...

Essentially, you first need to have installed the Apple Developer's Toolkit which you can download, free of charge, from the Apple Developer site. Follow the instructions for installing and testing the tools.

With the tool kit installed, and tested, you can then download the wxWidgets distribution for OS-X from the organisation's home page. Unzipping the single download file will create a substantial file tree with a root directory name of the form wxMac-n.n.n, where 'n.n.n' is the version number. I would recomend that you move this tree to the /Developer path created when you installed the Developer's Tool Kit. This just keeps everything together.

The next thing we have to do is make sure that the installation is correctly set up for your system. We do this by running configure, which has been installed with wxWidgets. Before we do this, we need to create a directory into which the wxWidgets libraries will be compiled. It's strongly suggested that you make this directory under your installation directory.

Let's start by running Terminal. Then the first thing we do when the terminal window is open, is to change to the installation directory...

$> cd ../../Developer/wxMac-2.6.1

Now create the directory that we're going to build the library in and then get into it...

$> mkdir osx-build
$> cd osx-build

We're ready to configure the installation for our needs. We call configure from the parent directory and tell it that we want a stand-alone library...

$> ../configure --disable-shared

This just sets up the makefile which will control the installation. You'll see a nice selection of messages as the process proceeds. When it's done, we're ready to create the library with which we'll link our application programmes. All that's required is to invoke make...

$> make

There will be a long wait while the compilation proceeds, there's a lot for it to do. Finally, if all is well, it will come to a natural halt. Now we can test it.

If we do the following...

$> cd samples/minimal
$> make

...we should see the compiler running. Provided it completes normally we do...

$> open minimal.appgt; open minimal.app

A window should open on the desktop and we should see a sample programme with the Aqua look and feel...


Minimal programme screenshot


There's not a lot this basic programme does other than display menus but that should be enough to prove that the installation has worked.

The reason for using open is that wxWidgets on the Mac creates bundled applications. Open is a Darwin executable which emulates, in a Terminal window, the process of double clicking on an application in Aqua.

You can see the effect of the bundling if you look at the samples/minimal directory from the Finder...




You'll notice that there are two 'minimal' applications shown. One is for the Classic environment (up to OS 9) and the other for OS-X. In practice, you'd distribute these in different directories, for the convenience of your users.
:

Followers

Who is this Sejanus character anyway?

I'm a British freelance Analyst Programmer who has spent the last 25 years working on everything from microcontrollers to mainframes. I use a wide variety of languages at work but try to stick to C and Perl for my own projects.