我一直在使用Flycheck,但我不确定如何让它正确识别Clutter。我根据我发现的教程,将这个(非常简单的)程序输入Emacs:
#include <stdlib.h>
#include <clutter/clutter.h>
//draws a basic, black window
int main(int argc, char *argv[])
{
ClutterInitError e = clutter_init(&argc, &argv); //pass it any
//options - these
//can be fed
if (e == CLUTTER_INIT_SUCCESS) {
ClutterColor stage_color = {0, 0, 0, 255}; //RGBA [0, 255]
ClutterActor *stage = clutter_stage_new();
clutter_actor_set_size(stage, 512, 512);
clutter_actor_set_background_color(stage, &stage_color);
clutter_actor_show(stage);
clutter_main();
return EXIT_SUCCESS;
} else {
return 1;
}
}
现在,在第2行(#include <clutter/clutter.h>
),我收到Flycheck发出的关于无法找到clutter/clutter.h
的警告。足够公平 - 在编译器中,我需要使用pkg-config
来成功编译它。在我的系统上,pkg-config clutter-1.0 --cflags --libs
输出:
-pthread -I/usr/include/clutter-1.0 -I/usr/include/pango-1.0 -I/usr/include/cogl -I/usr/include/cairo -I/usr/include/atk-1.0 -I/usr/include/pango-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/harfbuzz -I/usr/include/libpng16 -I/usr/include/cogl -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/include/libdrm -I/usr/include/json-glib-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -lclutter-1.0 -lcogl-path -lcairo-gobject -latk-1.0 -lpangocairo-1.0 -lpango-1.0 -lcairo -lcogl-pango -lcogl -lgmodule-2.0 -pthread -lgdk_pixbuf-2.0 -lwayland-egl -lgbm -ldrm -lEGL -lXrandr -ljson-glib-1.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lwayland-cursor -lwayland-client -lxkbcommon -lwayland-server -lX11 -lXext -lXdamage -lXfixes -lXcomposite -lXi
现在,我有点像C菜鸟(还有一点Flycheck菜鸟),所以请耐心等待。我知道我需要使用M-x customize-group flycheck-options
,在那里,我需要将一些内容放入Flycheck GCC Include Path
和Flycheck GCC Includes
。但是,我不知道上面输出的部分(如果有的话)在哪里?我真的很感激一些帮助,所以当我与其他图书馆合作时,我会知道如何正确设置它们。
答案 0 :(得分:2)
-I
输出中以pkg-config clutter-1.0 --cflags --libs
为前缀的所有路径都包含路径。
具体做法是:
/usr/include/clutter-1.0
/usr/include/pango-1.0
/usr/include/cogl
/usr/include/cairo
/usr/include/atk-1.0
/usr/include/pango-1.0
/usr/include/cairo
/usr/include/pixman-1
/usr/include/freetype2
/usr/include/libpng16
/usr/include/harfbuzz
/usr/include/freetype2
/usr/include/harfbuzz
/usr/include/libpng16
/usr/include/cogl
/usr/include/gdk-pixbuf-2.0
/usr/include/libpng16
/usr/include/libdrm
/usr/include/json-glib-1.0
/usr/include/glib-2.0
/usr/lib/glib-2.0/include
将这些内容添加到Flycheck GCC Include Path
。