Skip to main content

wxWidgets and Eclipse

maybe this article can help someone trying to figure if to or how to run wxWidgets with c++ under linux/windows. but first some intro.

In the company i currently work in we are creating software for an embedded linux environment in c++.
Because of Development Tools available in Windows, (yes linux also has many development tools but most are not as good as the MS tools, i just say: debugger [you are of course invited to start an argue ;)]) i decided to make the code run on both platforms where possible.

then i had the idea to create a simulator with a GUI with which the status of the firmware can be shown . additionally it should be possible to "simulate" all non-hardware related parts on windows so that the software department could easily test their and our stuff.

my second approach to this GUI then were wxWidgets. Coming from .NET i only was familiar with windows.forms programming and very sparse MFC, but for one and a half months i also looked into creating swing applications in java. ok... well, i dont count my tries back in colleg, those were.... puny. as i am now coding c++ and no .NET anymore, the mono project was out of question for this.
so i started looking for something useful and after buzzwords like glade, gtk and wxWidgets flew by my head, i finally decided for wxWidgets as it seemed to be a quite easy framework.
unfortunately, getting wxWidgets running in no-unicode format on ubuntu proved to be a "bit" of a challenge. wxWidgets were the first tool i used so far that i had to compile myself before being able to use it. this is a very strange thing to do for a .NET coder.... well anyways, for windows, after converting the code to VisualStudio08 i got it to run quite fast, also thanks to the good wxWidgets Wiki in the net (though a bit dated).

On Linux i first tried the ubuntu apt-get installs for wxWidgets development. after loosing many hours (because of lack of no-unicode variants to install) i then decided to try to compile it myself. this gave me some weird errors because after compilation you then get a script to install this stuff.... but the install always failed, or lets say: after the installation the /include files werent where they were supposed to be. as an example, some of them were supposed to be in /usr/local/lib/wx/include/gtk2-ansi-debug-2.8
but there were only the directories without files existing.
i then found out with the help of my college that i needed to configure the install especially with a certain flag ... that should be set by default anyways. but apparently it wasnt, so i set that flag manually, set the other flags i needed like no-unicode, did another install and... it finally worked. hoooray. with wx-config --cppflags unicode=no i now could get the compiler flags i needed to include the wxWidgets stuff.
to get it running with eclipse (europa version) you just copy those generated compilerflags into : project properties -> c++ builder -> gcc c++ compiler -> miscellangelous
and do the same for the linker with wx-config --lib unicode=no or was it --libs.

now get your app running.... there are some designers out there to do so, but actually they are quite awful, arrh! nevermind, finally i had some things together. so far so difficult, but it got more complicated when i received an error when running my project. as soon as my code began with some manipulation of strings, it crashed, somewhere with basic size functions of std::string.
hm, bad... it took my another hour to find out with trial and error, that it worked if i changed my compiler options: i turned the debug level to maximum and turned of the optimisation. now it worked. hoooray....

see? i hate things like these. if you just use .NET or Java GUI Components , you do not need to spend HOURS getting some things to RUN. you just start and can concentrate on the framework. of course you neednt even COMPILE the things you wanna use. you just have them :)
but anyway wxWidgets is quite a nice tool in a way...

I managed to get some ugly-looking GUI with a webtreeview up and running in adequate time. well wxWidgets isnt bad i guess, but if you can decide, stick with doing such things with Swing or windows.forms they are much faster to do, plus are much easier to make look nice. plus if you wanna be cross plattform it seems you need some bigger testing on both machines. some events of the treeview as an example are different in linux to windows.

at least i now have some knowledge how to get GUI frameworks for c++ running on both major platforms. but actually for the future i would begin investigating how GTK behaves and works. it actually seems a much younger, stronger and active framework. wxWidgets is very old, documentations and stuff i find is from 10 years back (no kidding) so maybe i bet on the wrong horse.

happy free days or something like that

Comments