r5 - 14 Jun 2006 - 12:23:19 - DanHowardYou are here: OSAF >  Journal Web  >  ContributorNotes > HeikkiToivonenNotes > WxWidgetsInEclipse20060501

wxWidgets in Eclipse on Ubuntu

Compiling and debugging wxWidgets in Eclipse, with Eclipse project files.

I used the prebuilt wxWidgets project files for Eclipse created by Dan Howard. See also the wxWidgets wiki entry on this.

Install Eclipse and CDT

You could download Eclipse SDK and Sun Java separately, but I found that the Free Java (using gcj) also worked. Simply install eclipse-sdk package with Synaptic, apt-get or whatever your favorite package manager is.

Then install the CDT (C/C++ development) plugin for Eclipse. You may need to start eclipse with gksudo eclipse. Then using the Eclipse Plugin Update Manager install the CDT plugin, URL http://download.eclipse.org/tools/cdt/releases/eclipse3.1 (Help > Software Updates > Find and Install > New features > New remote site...)

For more information on Eclipse on Ubuntu: https://wiki.ubuntu.com/EclipseIDE

Get wxWidgets sources and Set Up Eclipse Project

Download and unpack wxGTK-2.6.3.tar.gz. Download and unpack wx_eclipse_cdt-2.6.tar.gz as a sibling of wxGTK. Please note: do NOT put these in the Eclipse workspace area. I put these in my home directory.

Next you need to build wxGTK from the command line once to create a needed setup.h file that the projects don't yet create automatically:

$ cd wxGTK-2.6.3
$ mkdir buildgtk
$ cd buildgtk
$ ../configure --with-gtk=2
$ make

Next, you should make these two changes to the Eclipse environment so that importing the Eclipse projects will be faster:

  • In Eclipse CDT view, disable automatic building: uncheck Project > Build Automatically
  • In Eclipse, disable automatic indexing for C++: Window > Preferences... > C/C++ > Indexing (select no indexing)

(After importing you may be able to re-enable those.)

Now, in the project view panel (by default on the left), right-click and select Import... You want to import an existing Eclipse project. Set the wx_eclipse_ctd-2.6 as root directory. Now, first time import just one project, for example Calendar. Once the importing is done you will see Eclipse is indexing stuff - hit the red square to stop the indexing task. Now just repeat until all the projects from wx_eclipse_ctd-2.6 are imported - you can do more than one at a time but you might want to import only about 5 at a time. Sometimes the importing process may get wedged and you may need to kill Eclipse.

Next we need to make a small change to wx_gtk2_core-2.6 project for Ubuntu: Right-click the project file, Properties... > C/C++ build > Linker > Libraries and remove Xxf86vm.

Build

You might be able to build all projects at once, there is a button on the toolbar. If that does not work for some reason, you could build the projects one by one by right-clicking on the project and selecting Build Project. An order that is known to work:

wxjpeg-2.6
wxpng-2.6
wxtiff-2.6
wx_base_net-2.6
wx_base_xml-2.6
wx_gtk2_html-2.6
wx_gtk2_media-2.6
wx_gtk2_qa-2.6
wx_gtk2_base_c-2.6
wx_gtk2_base-2.6
wx_gtk2_adv_c-2.6
wx_gtk2_adv-2.6
wx_gtk2_core_c-2.6
wx_gtk2_core-2.6
wx_gtk2_xrc-2.6

If you want to rebuild a project, select Project > Clean... from the menus, then build that project again. Do NOT do right-click, Rebuild Project... (Seems there is a bug with incremental building as well.)

Edit ld load paths

You need to edit /etc/ld.so.conf (or you could possible edit LD_LIBRARY_PATH and restart Eclipse after that) to include the full path to the directories that are found by running the following command in the wx_eclipse_cdt-2.6 directory:

$ find -type d -name Debug

and then running ldconfig (might need sudo).

Run/Debug

Open Calendar project and navigate to the Binaries > Calendar program and select it. Right-click, Debug As > Debug Local C/C++ application. You may be presented with some dialogs, defaults will work. After a while the debugger will stop in the beginning of the main function.

Additional Information, TODO etc.

See the README.txt file in the wx_eclipse_ctd-2.6 package.

Questions/improvements:

  • I believe these projects were hand-created, we should make it so that bakefiles can generate them
  • What would it take to do this for wxPython?
  • How to do these for Mac OS X?
  • It seems incremental builds are broken; I get an error from make when it tries to deal with the dependency files
  • Any way to get around the need to mess with ldconfig and/or LD_LIBRARY_PATHS? If it was possible to set this somewhere in the Eclipse IDE it would be acceptable.
  • Shouldn't need to build wxGTK by hand first
  • Shouldn't need to have wxGTK as sibling
  • Shouldn't require buildgtk in the wxGTK dir structure

-- HeikkiToivonen - 01 May 2006

Edit | WYSIWYG | Attach | Printable | Raw View | Backlinks: Web, All Webs | History: r5 < r4 < r3 < r2 < r1 | More topic actions
 
Open Source Applications Foundation
Except where otherwise noted, this site and its content are licensed by OSAF under an Creative Commons License, Attribution Only 3.0.
See list of page contributors for attributions.