Installing and configuring under Ubuntu

From WxWiki
Revision as of 19:20, 21 October 2012 by Gluxon (talk | contribs) (→‎Using other packages: Updated Ubuntu distribution)
Jump to navigation Jump to search

In Ubuntu you can install several ways. Both methods include getting packages using one of the APT package managers. You can use Synaptic, aptitude or the sudo apt-get install command to install these.

Using the packages that ship with Ubuntu

The packages you need to install depends on what programming language you'll use and how you will use wxWidgets.

Packages for compiling wxWidgets 2.8 applications in C/C++

If you select and install these packages the package manager will download and install everything you need:

libwxgtk2.8-dev libwxgtk2.8-dbg

If you don't have a C or C++ compiler yet, you can install one by installing this package:

build-essential

Packages for wxPython 2.8

Install these packages and you will get everything you need to make wxWidgets applications with Python:

python-wxtools python-wxgtk2.8-dbg

If you will use XRC you will also need the python-xml package.

Do you need a good IDE for writing your wxPython apps? Install the idle package.

Using other packages

It turns out that the out-of-the-box install of wxWidgets doesn't set the directories up correctly. Here is a step-by-step guide to installing and configuring wxWidgets in Ubuntu!

1.Skip to step 2 if you have gcc, g++ etc installed (i.e. build-essential). In the terminal (if you don't know what the terminal is you better read a little more on linux) type sudo apt-get install build-essential This will install all the neccessary programs needed to compile most applications.

2. Ubuntu doesn't install the latest version of wxWidgets and certain applications (like Code::Blocks) require you to have the new version so we add this to our source list. Type gksu gedit /etc/apt/sources.list and add this to the end of the file and save. Replace gutsy with the version of ubuntu you are using. (keep the "-wx" part) Note that as of August 2012 there are no packages for Ubuntu 11.10 (Oneiric) or 12.04 (Precise)

deb http://apt.wxwidgets.org/ natty-wx main
deb-src http://apt.wxwidgets.org/ natty-wx main

3. The packages are digitally signed, so you have to import the key to prevent errors. Type the following command into the terminal to do this

curl http://apt.wxwidgets.org/key.asc | sudo apt-key add -

Then, update your package list to add the new packages.

sudo apt-get update

4. If you have wxWidgets (the latest version) installed go to step 3. Install the wxWidgets library and headers by typing this in the terminal

sudo apt-get install wx2.8-headers libwxgtk2.8-0 libwxgtk2.8-dev

5. Now that all of that stuff is installed we have to get the directory structure correct. Still in the terminal

 cd /usr/include

This is where the include files for wxWidgets are.

ls | grep wx

You should see a folder called wx-2.8. If you don't you haven't installed the headers correctly.

Linking and Compiling

Normally when you include wxWidgets you say "wx/wx.h" however wxwidgets is in the subdirectory of wx-2.8/wx so what we are going to do is create a link to wx-2.8/wx.

sudo ln -sv wx-2.8/wx wx

thats all now your files should compile correctly

When you compile your files to include the wxWidgets libraries, add this to the end of your gcc command:

`wx-config --cxxflags` `wx-config --libs`