Install and Configure wxwidgets on Ubuntu Ronald Mak Department of Computer Engineering Department of Computer Science January 12, 2019 Introduction wxwidgets is a C++ library that allows you to develop and deploy interactive GUI-based applications (https://www.wxwidgets.org/). You can build the library on different platforms Windows, Mac, and Linux and therefore you can also build your applications with little or no code change on those platforms. We will download, configure, build, and install wxwidgets on Ubuntu, a variant of the Linux operation system. Ubuntu can be running directly on physical hardware, or it can be running in a virtual machine managed by VirtualBox. See https://www.ubuntu.com/. Using wxwidgets, you can develop C++ desktop applications that display windows and interactive controls such as buttons, menus, text boxes, etc. (Figure 1) Figure 1. Sample program widgets. 1
Related documents: Install and Configure VirtualBox on Windows http://www.cs.sjsu.edu/~mak/tutorials/installvirtualbox.pdf Install and Configure Ubuntu on a VirtualBox Virtual Machine http://www.cs.sjsu.edu/~mak/tutorials/installubuntu.pdf Install developer tools The Ubuntu distribution does not include developer tools such as the GNU gcc and g++ compilers and GNU. See https://help.ubuntu.com/community/installingcompilers and follow its instructions: Note: If you receive the error message Temporary failure resolving us.archive.ubuntu.com, the fix is to enter the following command: and then try again. See https://askubuntu.com/questions/884604/temporary-failure-resolving-usarchive-ubuntu-com-live-usb-rescue. After installing the developer tools, you should be able to verify that gcc, g++, and were properly installed by entering the following commands in the Ubuntu terminal (Figure 2): gcc -v g++ -v -v sudo apt-get update sudo apt-get upgrade sudo apt-get install build-essential sudo dhclient -v -4 Figure 2. Verify that gcc, g++, and were properly installed. 2
The GTK development package We will build wxwidgets on top of the GIMP Toolkit (GTK) libraries which are already installed in Ubuntu. GTK is a multi-platform toolkit for creating graphical user interfaces. See https://www.gtk.org/ We must first download and install the GTK development package. In the Ubuntu terminal, enter the following command on the command line: sudo apt-get install libgtk-3-dev Download wxwidgets Go to https://www.wxwidgets.org/downloads/ to download the latest stable release (currently 3.0.4). Click on the download link Source for Linux, macos, etc. to download the source files of the toolkit. To build and deploy the wxwidgets library on Ubuntu, we will have to configure, compile, link, and install it. The download includes shell scripts that will run in an Ubuntu terminal to perform these operations. Unzip the downloaded zip file in your home directory to create a folder named wxwidgets-version, such as wxwidgets-3.0.4. Build and install wxwidgets Enter your wxwidgets directory, create a new subdirectory gtk-build, and enter it: mkdir gtk-build cd gtk-build Configure and build the wxwidgets libraries (takes a long time): Install the libraries: The wxwidgets libraries are installed in the standard location /usr/local/lib. The wxwidgets include files are installed in the standard location /usr/local/include. Build all the sample programs (takes a long time): Build all the demo programs:../configure -with-gtk sudo su install ldconfig exit cd samples cd../demos 3
Run the example programs You should now be able to run at least the minimal sample program (Figure 3): cd../samples/minimal./minimal Figure 3. Sample program minimal. Sample program widgets demonstrates all the interactive control (Figure 1): cd../widgets./widgets 4
Demo program forty (Figure 4): cd../../demos/forty./forty Figure 4. Demo program forty. For complete build and installation instructions, see the text files in subdirectory docs/gtk of your wxwidgets directory. See also https://wiki.wxwidgets.org/compiling_and_getting_started 5