logo
Home » Additional Information » How to install and configuring wxWidgets on Ubuntu and Windows

How to install and configuring wxWidgets on Ubuntu and Windows

Ubuntu


1.Download wxWidgets from the wxWidgets website and save it to a download directory. I found the wxGTK version worked for Fedora 11 and Ubuntu 10.04.

When deciding on the directory to download to, note as part of the installation there is an option to install the libraries and include files to /usr/local so it is ok to download to a user directory.
 
2.Extract the achieve file to a new directory.I used the Extract Here option available when the file is right mouse-clicked when viewed with a graphical file manager.
 
3.Open a terminal and cd to the folder you unzipped the achieve file into.
$ cd wxGTK-2.8.10
 
4.create a build directory within wxWidgets directory. This is typically build with additional letters appended to signify the build options. Later I'm going to build a release version with Unicode support, so I'll append an r and a u. d is suggested for a debug build.
$ mkdir buildur
$ cd buildur
$
 
5.run the configure script. There are many different parameters, (to see them run ../configure --help). I used the "most important" parameters as listed in the wxWidgets book.
$ ../configure --enable-unicode --disable-debug --disable-monolithic --disable-shared
$
  (the above is a single command / line. The appearance of two lines is due to text wrapping due to space limitations)
 
6.Build the wxWidgets installation
$ make
$
 
7.Update the compiler and linker configuration in the application's Makefile or configure its KDevelop or other project.If you use a text editor to write your source code, (as opposed to an IDE), or are only interested in compiling the application from source code, you may need to update the Makefile with the location of the wxWidgets include files and libraries on your system. This is done as follows,
 
  From the shell, use the wx-config shell script to get the compile flags. Copy the output into the application's Makefile (cxxflags macro definition) and add any other compile flags you like, e.g. -Wall
 
$ wx-config --cxxflags
$
  then use the wx-config shell script to get the library options. Copy the output into the application's Makefile (libs macro definition) and add any other library or linker options you need.
 
$ wx-config --libs
$
 
 Alternatively, if you want to use an IDE to edit the source code, following are instructions for KDevelop and codelite.Configure a KDevelop project as follows,
(the wxWidgets book recommends creating the KDevelop project as a Simple Hello World Program or some other minimal project setting, rather than using the wxWidgets project option, as it is not as flexible). However, I had a some problems (with automake) and was only able to build a wxWidgets application by creating the New Project as an Empty Custom Makefile Template project. This allowed me to use the same Makefile (see above) as if I was building the project using a text editor and running make from the terminal.
 
  You will need to make the following configuration changes;
Project > Project Options - Build Options (from the pane of options on the left)
Select the Build tab. Set the Build Tool as make, and Run the build tool in the following directory as the directory with the Makefile in it, (typically the build sub-directory)
 KDevelop, Project Options, Build Options
 
  Project > Project Options - Run Options (from the pane of options on the left)
Set the Main Program - Executable directory as the directory with the Makefile in it, (typically the build sub-directory). Note KDevelop seems to have a problem if the directory path contains as space in a directory name.
 
  If you are using codelite,
  create a new project and configure as follows,
open the Active Project Settings from the Workspace menu.
 Codelite, open active project settings
Codelite, project settings, general
 
  Select the Compiler tab and copy the result of the wxWidgets compiler settings shell script (see above), into the Compiler Options: settings.
You can copy and paste (and edit as required) the following into the dialog;
-I/usr/lib/wx/include/gtk2-unicode-release-2.8 -I/usr/include/wx-2.8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D__WXGTK__ -pthread

You will need to do this for all the configurations (e.g. Release and Debug) you need to use.
Note: the Debug configuration default compiler option is -g, so append the wxWidget compiler options to this.
 codelite, Project Settings, compiler
  Project Settings: Compiler
 
  Select the Linker tab and copy the result of the wxWidgets linker settings shell script (see above), into the Options: settings.
You can copy and paste (and edit as required) the following into the dialog;
-pthread -Wl,-Bsymbolic-functions -lwx_gtk2u_richtext-2.8 -lwx_gtk2u_aui-2.8 -lwx_gtk2u_xrc-2.8 -lwx_gtk2u_qa-2.8 -lwx_gtk2u_html-2.8 -lwx_gtk2u_adv-2.8 -lwx_gtk2u_core-2.8 -lwx_baseu_xml-2.8 -lwx_baseu_net-2.8 -lwx_baseu-2.8

You will need to do this for all the configurations (e.g. Release and Debug) you need to use.
Note: the Release configuration default linker option is -O2, so append the wxWidget linker options to this.
 codelite, Project Settings, linker
  Project Settings: Linker

Windows

The following description is for how to install and use wxWidgets on a Windows P.C. (I've only tested on XP), using the free tool-set MinGW and MSYS. Together these provide you a free software development environment on Windows.

MinGW is a native Windows port of the GNU Compiler Collection (GCC) that includes Windows headers and import libraries for building Windows applications. MSYS provides an environment closely resembling a Linux or Unix shell in which to use MinGW.

1.Download the MinGW GNU tool-set. If you use a text editor to write your source code, (as opposed to an IDE), or are only interested in compiling the application from source code, you can install MinGW directly. The easiest way is to download an installer executable, save to a suitable folder and run it, (current version is MinGW-5.1.6.exe, but I'm still using MinGW-3.1.0.exe). Refer in particular the cautions in HOWTO Install the MinGW GCC Compiler Suite.
 
If you want to use an IDE to edit the source code, download and run to the installer executable for MingGW Developer Studio (MingGWStudioFullSetup-2.05.exe) which is an excellent IDE. This also installs the MinGW tool-set.
Warning! I can't remember which site I got my version from, it was is 2007, and according to The Game Programming Wiki it's not being developed any more and the link provided doesn't work. I found the above link Google, so you may want to look around the Internet and make sure you feel comfortable with the site you're downloading an Windows .exe from.
 
2.Download the MSYS installer executable (i.e. MSYS-1.0.11.exe or MSYS-1.0.10) to a download folder and run it.The file is found in the MSYS Base System folder and then either the MSYS-1.0.11 or MSYS-1.0.10 folder.
I'm using MSYS-1.0.10.
 
3.Download wxWidgets from the wxWidgets website and save it to a download folder. Get wxMSW-2.8.10-Setup.exe for Windows
 
4.Run the installer executable.I install to the default folder of C:\wxWidgets-2.8.10
 
5.From the Windows Start menu, start a MSYS terminal
Windows Start
Start MSYS
and cd to the folder you installed wxWidgets to.
$ cd c:/wxWidgets-2.8.10
$
  (if you want to use DOS folder specification, you need to use quote marks around the folder path, e.g. "C:\wxWidgets-2.8.10")
 
6.Create a build directory within wxWidgets directory. This is typically build with additional letters appended to signify the build options. Later I'm going to build a release version with Unicode support, so I'll append an r and a u. d is suggested for a debug build.
$ mkdir buildur
$ cd buildur
$
 
7.Run the configure script. There are many different parameters, (to see them run ../configure --help). I used the "most important" parameters as listed in the wxWidgets book.
$ ../configure --enable-unicode --disable-debug --disable-monolithic --disable-shared
$
  (the above is a single command / line. The appearance of two lines is due to text wrapping due to space limitations)
 
8.Build the wxWidgets installation
$ make
$
 
9.Update the compiler and linker configuration in the application's Makefile or configure its MinGW Developer Studio project.In the Windows version of the wxWidgets, there is no wx-config script to find the values of cxxflags and libs, but the values in the Makefile can be replaced with the following,
 
  Update the Makefile as follows,
(the configuration parameters are each a single line, the appearance of multiple lines is due to text wrapping because of space limitations,)
cxxflags = -I/c/wxWidgets-2.8.10/build28ur/lib/wx/include/msw-unicode-release-static-2.8 -I/c/wxWidgets-2.8.10/include -DHAVE_W32API_H -D__WXMSW__ -pipe -Wno-ctor-dtor-privacy -Wall -g0 -O2 -fno-rtti -fno-exceptions
(you will have to change the top folder, (i.e. c/wxWidgets-2.8.10) and the wxWidgets build folder (i.e. build28ur) to the folder names you used. Also the msw-unicode-release-static will need to be change based on the configuration you built, or want to use, if you have multiple ones, and 2.8 is the wxWidget release number and will also need to be changed as required.)
 
  lib_dirs = -L"C:/wxWidgets-2.8.10/build28ur/lib"

libs = -lwx_mswu_core-2.8 -lwx_mswu_adv-2.8 -lwx_mswu_html-2.8 -lwx_baseu_xml-2.8 -lwx_mswu_core-2.8 -lwx_baseu-2.8 -lwxtiff-2.8 -lwxjpeg-2.8 -lwxpng-2.8 -lwxzlib-2.8 -lrpcrt4 -loleaut32 -lole32 -luuid -lwinspool -lwinmm -lshell32 -lcomctl32 -lcomdlg32 -lctl3d32 -ladvapi32 -lwsock32 -lgdi32

ldflags = -pipe -s -mthreads, -Wl, --subsystem,windows -mwindows
 
and change the build directive to include the ${lib_dirs} and ${ldflags} macro references which aren't in the distributed (Linux) version of the Makefile,
<ProgramName> : ${objs}
       g++ -o $@ ${objs} ${lib_dirs} ${libs} ${ldflags}
  (the above is on two lines)
 
  If you are using an IDE, for example MinGW Developer Studio, create a new project and configure as follows,
Edit > Options menu
 MinGW Developer Studio Project options, include files
  (see the section on configuring the Makefile about changes to the folder names you may have to make based on your configuration.
You can copy and paste (and edit as required) the following into the dialog,)

C:\wxWidgets-2.8.10\build28ur\lib\wx\include\msw-unicode-release-static-2.8
C:\wxWidgets-2.8.10\include
 
  Project Settings: Compiler
 MinGW Developer Studio, Project Settings, compiler
  (the default settings don't require modification)
 
  Project Settings: Linker
 MinGW Developer Studio, Project Settings, linker
  (see the section on configuring the Makefile about changes to the folder names you may have to make based on your configuration.
You can copy and paste (and edit as required) the following into the dialog. Each configuration parameter is a single line / entry, the appearance of multiple lines is due to text wrapping because of space limitations)

Libraries:
wx_mswu_core-2.8 -lwx_mswu_adv-2.8 -lwx_mswu_html-2.8 -lwx_baseu_xml-2.8 -lwx_mswu_core-2.8 -lwx_baseu-2.8 -lwxtiff-2.8 -lwxjpeg-2.8 -lwxpng-2.8 -lwxzlib-2.8 -lrpcrt4 -loleaut32 -lole32 -luuid -lwinspool -lwinmm -lshell32 -lcomctl32 -lcomdlg32 -lctl3d32 -ladvapi32 -lwsock32 -lgdi32

(note the "missing" -l from the first library in the list)

Extra linking options:
-mthreads, -Wl,--subsystem,windows -mwindows

Additional library path:
C:\wxWidgets-2.8.10\build28ur\lib