编译gtk3应用时出现致命错误:找不到glib.h

时间:2018-11-25 02:56:49

标签: c++ gtk gtk3 glib

我正在尝试编译gtk3 example program,但是我经常遇到错误。

我已经在Google搜索了大约两个小时,但找不到解决方案。

传递的命令:

g++ -m64 -std=c++17 ./src/gtkbuildtest.cpp -o ./debug/gtkbuildtest `pkg-config --cflags --libs glib-2.0 gtk+-3.0`

引发错误:

In file included from /usr/include/gtk-3.0/gdk/gdk.h:30,
             from /usr/include/gtk-3.0/gtk/gtk.h:30,
             from ./src/globalincludes.hpp:18,
             from ./src/gtkbuildtest.cpp:1:
/usr/include/gtk-3.0/gdk/gdkconfig.h:13:10: fatal error: glib/glib.h: No such file or directory
#include <glib/glib.h>
         ^~~~~~~~~~~~~
compilation terminated.

pkg-config的输出:

-pthread -I/usr/include/gtk-3.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/usr/include/gtk-3.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/cairo -I/usr/include/libdrm -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/fribidi -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0

系统版本:

Ubuntu 18.10

我不知道为什么glib无法正确链接。

感谢您的帮助。

1 个答案:

答案 0 :(得分:2)

我不确定,但是#include <glib.h>(而不是#include <glib/glib.h>)可能会帮助您。 (glib.h不在glib目录中。)