cgccemacsclutterflycheck

Flycheck and Clutter - how can I set it up?


I've been using Flycheck for a while, but I'm not sure how to make it recognize Clutter properly. I typed this (very simple) program, based on a tutorial I found, into 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;
  }
}

Now, on line 2 of that (the #include <clutter/clutter.h>), I get a warning from Flycheck about not being able to find clutter/clutter.h. Fair enough - in a compiler, I would need to use pkg-config to successfully compile it. On my system, pkg-config clutter-1.0 --cflags --libs outputs:

-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

Now, I'm a bit of a C noob (and a bit of a Flycheck noob), so bear with me. I know that I need to use M-x customize-group flycheck-options, and in there, I need to put some stuff into Flycheck GCC Include Path and Flycheck GCC Includes. However, I don't know what (if any) part of the above output goes where? I would really appreciate some help, so then, when I work with other libraries, I'll know how to set them up properly.


Solution

  • All the paths prefixed with -I in your pkg-config clutter-1.0 --cflags --libs output are include paths.

    Specifically:

    /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
    

    Add those to Flycheck GCC Include Path.