简体   繁体   中英

Fatal error when compiling gtk3 app: glib.h not found

I was trying to compile the gtk3 example program and I am constantly getting an error.

I have been searching google for about two hours and I cant find a solution for this.

Command passed:

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

Error thrown:

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.

Output of 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

System Version:

Ubuntu 18.10

I don't know why glib wont link properly.

Any help is appreciated.

I'm not sure, but may be #include <glib.h> (instead of #include <glib/glib.h> ) will help you. (glib.h are not in glib directory).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM