1
votes

I installed gtkmm 3 on Ubuntu 13.04 using aptitude (I like aptitude because it remembers what was installed when you want to remove it):

sudo aptitude install libgtkmm-3.0-dev --with-recommends

Using codelite 5.1.2 and the default gtk++ tool chain, in my compiler include paths I added:

/usr/include/gtkmm-3.0 - the path to gtkmm.h

I tried to build the first sample app in Programming with GTKMM:

#include <gtkmm.h>
int main ( int argc, char *argv[] )
{

    Gtk::Main kit ( argc, argv );
    Gtk::Window window;
    Gtk::Main::run ( window );
    return 0;

}

After chasing down a few 'include file not found' errors coming from gtkmm.h, which includes the entire gtkmm framework, my compiler include path now looks like this:

/usr/include/gtkmm-3.0
/usr/include/glibmm-2.4
/usr/lib/i386-linux-gnu/glibmm-2.4/include
/usr/include/glib-2.0

And all hell is breaking loose from glib.h:

/bin/sh -c 'make -j 4 -e -f  "Calendars_wsp.mk"'
----------Building project:[ CalendarsGUI - Debug ]----------
........

/gtkmm-3.0 -I/usr/include/glibmm-2.4 -I/usr/lib/i386-linux-gnu/glibmm-2.4/include -I//usr/include/glib-2.0
In file included from //usr/include/glib-2.0/glib/gtypes.h:36:0,
                 from //usr/include/glib-2.0/glib/galloca.h:34,
                 from //usr/include/glib-2.0/glib.h:32,
                 from /usr/include/glibmm-2.4/glibmm/thread.h:46,
                 from /usr/include/glibmm-2.4/glibmm.h:87,
                 from /usr/include/gtkmm-3.0/gtkmm.h:87,
                 from main.cpp:16:
***//usr/include/glib-2.0/glib/gversionmacros.h:179:2: error: #error "GLIB_VERSION_MIN_REQUIRED must be >= GLIB_VERSION_2_26"***
In file included from //usr/include/glib-2.0/glib/galloca.h:34:0,
                 from //usr/include/glib-2.0/glib.h:32,
                 from /usr/include/glibmm-2.4/glibmm/thread.h:46,
                 from /usr/include/glibmm-2.4/glibmm.h:87,
                 from /usr/include/gtkmm-3.0/gtkmm.h:87,
                 from main.cpp:16:
***//usr/include/glib-2.0/glib/gtypes.h:448:2: error: #error unknown ENDIAN type
.......
make: *** [All] Error 2
2 errors, 2 warnings***

(I also had the same problems when trying to use gtkmm 2.4)

Obviously I am missing something here. What am I doing wrong? What else do I need to do to build gtkmm projects?

2
This error message seems pretty clear to me: #error "GLIB_VERSION_MIN_REQUIRED must be >= GLIB_VERSION_2_26", and you seem to have only version 2.0 of glib installed.Some programmer dude
Would seem you're right - but I installed 3.0 based on the instructions on the GTKMM website, and the only version of glib.h out there seems to be the one I've got. GTKMM docs do say that the installed version doesn't always sync up with actual code base they release.Vector
@JoachimPileborg - seems that I am not alone. On SE/AskUbuntu there are a lot of similar questions. They're saying Unity doesn't seem to get along so well with gtkmm.... BTW, thanks for edit.Vector

2 Answers

4
votes

When using gtkmm, its advised to use the pkg-config tool. You can do this from codelite as well:

Right click on your project: Settings -> Common Settings -> Compiler -> C++ Compiler options: and add:

$(shell pkg-config gtkmm-3.0 --cflags)

If you have another options, they should be semi-colon delimited

Next, add the following to the linker options: Right click on your project: Settings -> Common Settings -> Linker -> Options:

$(shell pkg-config gtkmm-3.0 --libs)

again, if you have another options, they should be semi-colon delimited

Remove all the hard coded include paths you added the above 2 should suffice

Note:

This exact question was also answered on codelite's forum: http://forums.codelite.org/viewtopic.php?f=11&t=1396&p=6416&hilit=gtkmm#p6410

Eran

3
votes

Don't fiddle with includes, use pkg-config instead:

g++ foo.cc -o foo `pkg-config gtkmm-3.0 --cflags --libs`

btw, your example compiles and runs just fine.