我是C的新人,并开始学习如何创建GUI。 出于某种原因,程序运行的唯一方法是
gcc simple.c -o simple -lgtk-3 -lgdk-3 -latk-1.0 -lgio-2.0 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lcairo-gobject -lpango-1.0 -lcairo -lgobject-2.0 -lglib-2.0 -pthread -I/usr/include/gtk-3.0 -I/usr/include/atk-1.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/pixman-1 -I/usr/include/libpng12
如果我只是运行gcc simple.c
它会给我
In file included from /usr/include/glib-2.0/glib/galloca.h:32:0,
from /usr/include/glib-2.0/glib.h:30,
from /usr/include/glib-2.0/gobject/gbinding.h:28,
from /usr/include/glib-2.0/glib-object.h:23,
from /usr/include/glib-2.0/gio/gioenums.h:28,
from /usr/include/glib-2.0/gio/giotypes.h:28,
from /usr/include/glib-2.0/gio/gio.h:26,
from /usr/include/gtk-2.0/gdk/gdkapplaunchcontext.h:30,
from /usr/include/gtk-2.0/gdk/gdk.h:32,
from /usr/include/gtk-2.0/gtk/gtk.h:32,
from graphical.c:1:/usr/include/glib-2.0/glib/gtypes.h:32:24: fatal error: glibconfig.h: No such file or catalog compilation terminated.
如果我做其他传统的'包含lib的方法:
gcc `pkg-config gtk+-2.0 --cflags` example.c -o example `pkg-config gtk+-2.0 --libs`
它给了我:
Package gtk+-2.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gtk+-2.0.pc' to the PKG_CONFIG_PATH environment variable
No package 'gtk+-2.0' found
graphical.c:1:21: fatal error: gtk/gtk.h: No such file or catalog
包含GTK的正确方法是什么?
答案 0 :(得分:0)
我只知道问题是什么。 我安装了linuxbrew,由于某种原因pkg-config从其中一个repos中获取路径,即使我强制它导出。 我完全删除了linuxbrew,现在它终于工作了! :)