3

I'm coding in Eclipse CDT in C++ with gtkmm. I have managed to set up Eclipse so it compiles the code correctly, by adding pkg-config gtkmm-3.0 --cflags --libs to the compiler options. So it runs, and works. But in the editor is everything gtk related underlined with red and when I hover over those parts, it says something like: Type 'Gtk::Main' could not be resolved. So I could code like this, but it's really a pain with autocompletion not working and red lines all over the screen. How can I solve this?

My code looks something like this:

#include <gtkmm-3.0/gtkmm.h>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
    Gtk::Main kit(true);

    Gtk::Box* box = new Gtk::Box();

    ...

However, I don't think it's related to the code. Because it works fine in Code::Blocks, with code completion and all. But I prefer Eclipse over C::B.

// Daniel

Daniel Jonsson
  • 3,261
  • 5
  • 45
  • 66
  • I made in complete procedure for this [here](https://stackoverflow.com/questions/58910311/configured-eclipse-for-gtkmm-and-gtk-on-ubuntu/62203484#62203484). – BobMorane Jun 04 '20 at 20:34

2 Answers2

4

Select Project -> Properties from the menu to open the properties window. Then in the selector on the left, go to C/C++ general -> Paths and symbols. You will see a list of Include directories. Look at the output of pkg-config --cflags gtkmm-3.0 and make sure all the directories mentioned there are also in this list.

Note that these are the paths in which Eclipse's syntax checker looks for include files. Your code compiles fine, because the compiler is finding these files the way it should.

ptomato
  • 56,175
  • 13
  • 112
  • 165
  • Thank you very much! It seems to work perfectly. However, is there a easy and fast way to add them? And do I have to repeat this for all gtkmm projects? – Daniel Jonsson Nov 20 '11 at 23:20
  • Sorry, I haven't found a better way to do it automatically or easily. – ptomato Nov 21 '11 at 07:41
  • You can expand `pkg-config --cflags gtkmm-3.0` like it is suggested in the answer and add the output manually in the XML project file from the eclipse. Using rectangular selection (`Shift + Alt + A` to enable), it can be done pretty fast. – BobMorane Feb 14 '18 at 01:41
2

As ptomato said, the paths have to be configured. A very simple way is to use the pkg-conf plug-in. After installing you just need to select gtkmm-3.0 in the configuration. The rest will be done by the plug-in. Hope this picture helps. Be aware: The Screenshot shows the conf. for GTK-2.0. You need the GTKMM-3.0 .

Fat Noodle
  • 105
  • 1
  • 8