Building wx from source

From LSDevLinux
Jump to: navigation, search

It's best to obtain the wx sources using Subversion and then to keep this source directory available for upgrading to the next minor release of wx, which happens every few months. Subversion avoids re-downloading the large amount of source code that hasn't changed since the previous release.

Checking out the sources

Check out the sources from a tagged release in Subversion. Subversion repositories conventionally have a top-level directory structure containing the subdirectories trunk, branches and tags. So, for example, to check out wx 2.8.9:

$ svn co http://svn.wxwidgets.org/svn/wx/wxWidgets/tags/WX_2_8_9 wxWidgets

This will create a directory called wxWidgets to hold the checkout.

To find out the latest tag, use Subversion's ls command:

$ svn ls http://svn.wxwidgets.org/svn/wx/wxWidgets/tags/ | grep '^WX_[0-9]'

However, also check which wx version your project needs since it may not be compatible with the latest.

Installing development packages

Linux

The following library packages are needed:

  • libgtk2.0-dev
  • libgtk2.0-0-dbg

Install these using Synaptic Package Manager.

The following packages are helpful, but not essential. If they aren't present, wx will use internal equivalents.

  • libexpat1-dev
  • libjpeg8-dbg
  • libjpeg8-dev
  • libpng12-dev
  • libtiff4-dev
  • zlib1g-dbg
  • zlib1g-dev

Mac OS X

Nothing extra required.

Configure and build

wx supports "out-of-tree" builds, which simply means that you can do the build in a separate directory rather than in the source tree itself. This makes it easier to clean everything out ready for upgrading. The directory can be a subdirectory of the source tree, so we create a top-level subdirectory to hold the build. It's helpful to name this according to the build configuration that it will hold, for example build-ud for a Unicode Debug build. We then change to this directory and run configure and make:

$ mkdir build-ud
$ cd build-ud
$ ../configure --enable-debug --enable-unicode
$ make

If you have a multi-core machine you can speed up the build considerably by giving a -j option to make, followed by a number that is one more than the number of cores that you have. For example, on a dual-core machine you would use make -j3.

If all goes well, you can follow this with sudo make install. The destination directory ("prefix") will have been set when you run configure, and by default it is /usr/local. The libraries will go into /usr/local/lib and the headers into /usr/local/include. Your SA build should then pick up

Upgrading to a new release

Use Subversion's switch command to update the sources in your tree from a different tag. For example, to upgrade to wx 2.8.10:

$ svn switch http://svn.wxwidgets.org/svn/wx/wxWidgets/tags/WX_2_8_10

Get rid of the old build with rm -rf build-ud and then follow the steps given above for a new configure and build.