1

我使用 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 行(第 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 Pathand Flycheck GCC Includes。但是,我不知道上述输出的哪一部分(如果有)去了哪里?我真的很感激一些帮助,所以当我使用其他库时,我会知道如何正确设置它们。

4

1 回答 1

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.

于 2014-09-24T11:31:06.183 回答