问题
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
回答1:
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.
回答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 .
来源:https://stackoverflow.com/questions/8204245/eclipse-cdt-gtkmm-could-not-be-resolved-but-compiles-and-runs