编译gtkmm的问题 [英] Problems compiling gtkmm

查看:604
本文介绍了编译gtkmm的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

操作系统:Fedora 14

OS: Fedora 14

编译器:g ++(GCC)4.5.1 20100924(Red Hat 4.5.1-4)

Compiler: g++ (GCC) 4.5.1 20100924 (Red Hat 4.5.1-4)

我安装了gtkmm24-devel从存储库通过yum。为了确保安装按计划进行,我决定尝试页面上的一个示例。

I installed gtkmm24-devel from repository via yum. To make sure the install went as planned I decided to try one of the examples on the page.

#include <gtkmm.h>

int main(int argc, char *argv[]) {
    Gtk::Main kit(argc, argv);
    Gtk::Window window;
    Gtk::Main::run(window);
    return 0;
}

我运行的例子,它说它找不到gtkmm.h,没问题,我只是忘了链接库。我添加了/usr/include/gtkmm-2.4到我的库通过Eclipse搜索。没有bueno,g ++仍然找不到它!

I ran the example, and, hey! It said it couldn't find gtkmm.h, no problem, I just forgot to link the library. I added /usr/include/gtkmm-2.4 to my library search through Eclipse. No bueno, g++ still can't find it!

fatal error: gtkmm.h: No such file or directory

然后,我尝试使用 #include< gtkmm-2.4 / gtkmm包括gtkmm。 h> 并重新编译,另一个错误! :(

I then try to include gtkmm by using #include <gtkmm-2.4/gtkmm.h> and recompile, another error! :(

/usr/include/gtkmm-2.4/gtkmm.h:87:20: fatal error: glibmm.h: No such file or directory

感谢您阅读。

推荐答案

简短回答

使用'pkg-config gtkmm-

Use the output of 'pkg-config gtkmm-2.4 --cflags' for include paths and 'pkg-config gtkmm-2.4 --libs' for libraries to link.

长回答


它说它找不到gtkmm.h,没问题,我只是忘了链接库。

It said it couldn't find gtkmm.h, no problem, I just forgot to link the library.

构建C / C ++程序分为两个步骤:首先编译源文件,输出目标文件;然后将目标文件链接在一起。

Building a C/C++ program is done in two separate steps. First the source files are compiled, outputting object files; and then the object files are linked together. The error you are getting comes from the compiling step.

在Linux上,大多数库都带有pkgconfig文件,使得其他程序更容易使用库。gtkmm还带有自己的pkgconfig文件。

On Linux, most libraries come with pkgconfig files to make it easier for other programs to use the libraries. gtkmm also comes with its own pkgconfig files.

您正在尝试手动为include路径指定/usr/include/gtkmm-2.4;这是错误的。相反,使用pkgconfig的输出来确定头文件的位置。要获取gtkmm所需的所有包含目录,请使用以下命令:

You are trying to manually specify /usr/include/gtkmm-2.4 for include path; this is wrong. Instead, use the output of pkgconfig to figure out where the header files are located. To get all the include directories needed for gtkmm, use the following command:

pkg-config gtkmm-2.4 --cflags

要链接,请使用以下pkgconfig命令获取您需要链接的库:

For linking, use the following pkgconfig command to get the libraries you need to link with:

pkg-config gtkmm-2.4 --libs

您可以直接通过调用g ++在命令行上测试。

You can test it on the command line by invoking g++ directly.

g++ myfirstprogram.cpp -o myfirstprogram `pkg-config gtkmm-2.4 --cflags --libs`

有关详细信息, gtkmm文档: http://library.gnome.org/devel /gtkmm-tutorial/unstable/sec-basics-simple-example.html.en

For more information, see the gtkmm docs: http://library.gnome.org/devel/gtkmm-tutorial/unstable/sec-basics-simple-example.html.en

这篇关于编译gtkmm的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆