Building WxWidgets With MacOS X

From WxWiki
Jump to: navigation, search

These are notes for building wxWidgets on MacOS X using the command-line tools. If you are interested in using XCode, see the Mac OS X And Xcode For Beginners tutorial.

First, here is the process for building version 2.8.4 with default configuration options.

You need to install developers tools, usually included on the mac OS X install DVD, alternatively downloadable for free from Apple's website.

Usually, the process will be go fine. However, if you encounter build errors because your GCC version is unsupported, or if you just want backwards compatibility, you can use another verison of XCode by running this on a terminal:

sudo /usr/sbin/gcc_select 3.1

The basic procedure for building with the command-line tools is outlined here. The standard install will place libraries in /usr/local/lib, standard wxWidgets headers in /usr/local/include, and the generated setup.h under /usr/local/lib/ (this last piece is a common source of confusion).

Alternatively, you can choose to keep your build in place.

2.8.4 with command-line tools

The instructions overall assume you know the basics of working with the terminal. (/Applications/Utilities/Terminal)

1. move to the wxMac-2.8.4 directory. (hint: type "cd ", and then drag and drop the wxMac folder on the terminal. Then press enter)

2. mkdir macbuild && cd macbuild

3. ../configure (There are many options you can give to the configure script. The defaults will give you a shared library with debugging disabled).

 * For a static lib, pass --disable-shared.
 * For OpenGL support, pass --with-opengl.
 * For debug, use --enable-debug.
 * ../configure --help will list all other possible options.

4. make (wxWidgets will now build. This will take some time.)

5. sudo make install

This will install wxWidgets into /usr/local folders. If you do not wish to install it there, you can skip this step and instead have wxWidgets projects use the wx-config found at wxMac-2.8.4/macbuild/wx-config)

To test your build, you will want to build the samples:

Samples

In the samples directory, there are many samples. If you want to build, e.g., widgets:

6. cd ./samples/widgets

7. make

8. open ./widgets.app

Make sure you cd into the Samples folder that is contained inside the new 'macbuild' folder cretaed above, not the one in the main wxWidgets folder