Compiling and getting started
This is a guide to help you getiing started quickly and easily on Linux with wxWidgets built from source.
Install all necessary build tools, including g++ and autotools. (On Ubuntu, you will want to install package build-essential)
You will also need gtk+ (don't forget to install the -dev package if your distro uses them)
It is recommended to use at least GTK+ 2.2.3, and some features are only available when using more recent version, like GTK+ 2.8.
Download the wxGTK source archive from http://www.wxwidgets.org/downloads/ and expand it. If you intend to use it in place (not install it in system dirs) choose a place where it can stay forever because you won't be able to move it without breaking the build.
Then, the following steps are done on the terminal.
adapt path as needed
mkdir gtk-build cd gtk-build
we create a new folder to build from, this enables us to have many wxWidgets builds, for instance a debug and a release one, or a Unicode and an ANSI one, or a static and a shared one, etc.
Then you will need to call configure with something like ../configure --enable-unicode The options you pass to configure at this point will determine what build you get. --enable-unicode will make a Unicode build --with-opengl will enable OpenGL support --disable-shared will build static libs instead of shared ones --prefix= allows you to let wxWidgets be installed at other lcoations than the default /usr/local for a list of all possible options, write ../configure --help
If it stops saying it can't find a package, install it (with -dev packages if any) and run configure again.
When it is done without errors you are ready to build.
When the build is done, and if no error occured, you can now install it
sudo make install
Enter your password as needed. wxWidgets will be installed in /usr/local/
Open a terminal and type
It should be the version you just built. If it is not, try running
and see if it is the one you just installed (if you did not change the default value, you installed /usr/local/bin/wx-config)
if you get something like /usr/bin/wx-config while you installed /usr/local/bin/wx-config, it means there is another version of wxWidgets installed somewhere else, probably installed by the system. You can quickly get it out the way with a hacky command like sudo mv /usr/bin/wx-config /usr/bin/wx-config-old1.
Then, to test more in depth, you can look at the samples. Open the Samples folder located at wxGTK-2.8.4/gtk-build/samples (be careful : wxGTK-2.8.4/samples contains the source code, while wxGTK-2.8.4/gtk-build/samples contains the makefiles for your system. for building samples, you wil lwant to cd into the latter, while to study the code you will want to open the former)
cd into one of the samples, and type make. You can then open the sample to see wxWidgets i naction.
Building apps with wxWidgets
The tool wx-config allows you to quickly build wxWidgets apps
g++ `wx-config --cppflags` `wx-config --libs` widgetTest.cpp
wx-config --cppflags returns flags necessary to compilation, wx-config --libs returns flags necessary to linking. This little example has a single file so both are used at the same time but in a bigger project compiling and linking will most likely be two different steps. (How to use g++ is beyong the scope of this document)
Running wxWidgets projects
If when running a wxWidgets app you get an error like:
./a.out: error while loading shared libraries: libwx_gtk2_aui-2.8.so.0: cannot open shared object file: No such file or directory
this means your system does not search for libs in /usr/local/libs (or wherever you installed wxWidgets) by default. To solve this, write 'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib' on the terminal before opening the executable (from the same terminal). You can change the LD_LIBRARY_PATH vraiable permanently to avoid this issue.