Eclipse CDT 和gtkmm:“...无法解析。”,但编译并运行
我正在使用 gtkmm 在 C++ 中的 Eclipse CDT 中进行编码。我已成功设置 Eclipse,以便通过将 pkg-config gtkmm-3.0 --cflags --libs
添加到编译器选项来正确编译代码。所以它运行并且有效。但在编辑器中,与 gtk 相关的所有内容都用红色下划线表示,当我将鼠标悬停在这些部分上时,它会显示如下内容:无法解析类型“Gtk::Main”
。所以我可以像这样编码,但是自动完成功能不起作用并且屏幕上到处都是红线,这确实很痛苦。我该如何解决这个问题?
我的代码看起来像这样:
#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();
...
但是,我认为它与代码无关。因为它在 Code::Blocks 中工作得很好,具有代码完成等功能。但我更喜欢 Eclipse 而不是 C::B。
// 丹尼尔
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
选择项目 ->从菜单中的属性打开属性窗口。然后在左侧的选择器中,转到C/C++ 常规 -> 路径和符号。您将看到包含目录的列表。查看 pkg-config --cflags gtkmm-3.0 的输出并确保其中提到的所有目录也在此列表中。
请注意,这些是 Eclipse 语法检查器查找包含文件的路径。您的代码编译得很好,因为编译器正在按其应有的方式查找这些文件。
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 所说,必须配置路径。一个非常简单的方法是使用 pkg-conf 插件在。
安装后,您只需在 配置。
其余的将由插件完成。
希望这张图片有帮助。
请注意:屏幕截图显示了conf。对于GTK-2.0。您需要 GTKMM-3.0 。
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 .