Installing wxWidgets in a MinGW / MSYS environment


Note

This document is a so-called one-shot document. It is here to describe the installation of wxWidgets with MingW / MSYS for a certain version at a certain time (Spring 2006).

This document is not maintained. I will not answer support questions. I will not make changes or provide additional information.

If you feel like you would like to maintain this document, please let me know and I will provide you with the source files.

Prerequesites

You must have a working installation of MinGW and MSYS. MinGW must be installed with support for g++.

Obtaining wxWidgets

The current wxWidgets distribution can be downloaded from the wxWidgets website. In the left column, click on download. Then, under stable releases click on windows. In the sourceforge section, click on the installable version, at the time of this writing (Apr 06) called wxMSW-2.6.3-Setup-1.exe. Select a sourceforge mirror and wait for the download (approx. 17.5 MB).

Installing wxWidgets

Installing wxWidgets is easy and doesn't take long. Unfortunately you'll have to compile it afterwards, which takes a while. Here are some screenshots from the installation

Figure 1. wxWidgets asking if it should install

wxWidgets asking if it should install

Figure 2. the wxWidgets license

the wxWidgets license

When wxWidgets asks for an installation path, you may chose any path you like, but make sure it does not contain any spaces, as they will break some of the scripts. I would recommend the default setting.

Figure 3. where it should be installed

where it should be installed

Figure 4. and thats it!

and thats it!

The installation will set the WXWIN environment variable for you. You will have to log out and log back in to ensure that it is actually set for every program. (Rebooting works equally well).

Compiling wxWidgets

After you have downloaded wxWidgets, you need to compile it for your environment. This takes a while, so start it and then go get lunch.

You will have to use the MSYS window. You can find it in (Start / Programs / MSys / MSYS). This is a Unix-like environment in your windows computer.

Figure 5. The MSYS window

The MSYS window

Change to your wxWidgets directory:

cd $WXWIN

The yellow/orange part should show something like: /c/wxWidgets-2.6.3. If that is not the case, make sure you've logged out and back in.

Next, configure wxWidgets for your system. Type (all in one line!):

./configure --enable-optimise --enable-stl --enable-unicode 
  --disable-threads --enable-static --disable-shared --enable-monolithic

This takes a short while (on current computers about 5 minutes). So only grab a quick coke. It displays a lot, including warnings. It is very safe to just ignore those. When it is done it should show something like this (your output may be slightly different):

Configured wxWidgets 2.6.3 for `i686-pc-mingw32'

  Which GUI toolkit should wxWidgets use?                 msw
  Should wxWidgets be compiled into single library?       yes
  Should wxWidgets be compiled in debug mode?             no
  Should wxWidgets be linked as a shared library?         no
  Should wxWidgets be compiled in Unicode mode?           yes
  What level of wxWidgets compatibility should be enabled?
                                       wxWidgets 2.2      no
                                       wxWidgets 2.4      yes
  Which libraries should wxWidgets use?
                                       jpeg               builtin
                                       png                builtin
                                       regex              builtin
                                       tiff               builtin
                                       zlib               builtin
                                       odbc               no
                                       expat              builtin
                                       libmspack          no
                                       sdl                no
                                       gnomeprint         no
                                       hildon             no

Now compile wxWidgets by running make:

make

This takes a long time (between 20 minutes and 1 hour on modern systems) and has lots of output. Don't wait for it. Go do something else in the mean time.

Optimizing wxWidgets

Saving space

To save disk space, you may now delete the compiled object files. This does no harm, since they will be recreated if you compile again. In MSYS, type

cd $WXWIN
rm *.o

Improving compile time

You can "precompile" the wxWidgets header. This will save you compile time if - and only if - the #include <wx/wx.h> line is the first code line in your source file. To do that, type the following in MSYS:

cd $WXWIN
cd include/wx
g++ $(../../wx-config --cxxflags) wx.h

Further Examples

For a quickstart example and further information how to program wxWidgets using eclipse see my wxWidgets using Eclipse and the CDT HowTo.

Home

HowTo