How to repair “error: gdk-pixbuf/gdk-pixdata.h: No

2019-09-02 05:42发布

问题:

I need to rotate a Pixbuf. The vala code contains

using Gst, GLib, Posix, Sqlite, Gdk;
public class RotateSaveImage
{
    public void RotateSaveImage(string input, string output)
    {
        var img = new Pixbuf.from_file(input);
        var rotate_image = img.rotate_simple(PixbufRotation.CLOCKWISE);
        rotate_image.save(output, "jpeg");
    }
}

The makefile contains

test_VALAFLAGS = --vapidir=@VAPIDIR@ --pkg gstreamer-0.10 --pkg glib-2.0 --pkg gio-2.0 --pkg posix --thread --pkg gstreamer-app-0.10 --pkg sqlite3 --pkg gtk+-3.0

Shouldn't --pkg gtk+-3.0 add gdk-pixbuf/gdk-pixdata.h?

回答1:

Autotools will just use valac to translate the Vala code into C, then will use it's support for building C to actually compile to machine code. This means that you need to add the relevant information to *_CFLAGS ans *_LDFLAGS. Generally this is done by putting something like this in your configure.ac:

PKG_CHECK_MODULES(GIO_PIXBUF, gio-2.0)
AC_SUBST(GIO_CFLAGS)
AC_SUBST(GIO_LIBS)
PKG_CHECK_MODULES(GSTREAMER, gstreamer-0.10)
AC_SUBST(GSTREAMER_CFLAGS)
AC_SUBST(GSTREAMER_LIBS)
PKG_CHECK_MODULES(GSTREAMER_APP, gstreamer-app-0.10)
AC_SUBST(GSTREAMER_APP_CFLAGS)
AC_SUBST(GSTREAMER_APP_LIBS)
PKG_CHECK_MODULES(SQLITE, sqlite3)
AC_SUBST(SQLITE_CFLAGS)
AC_SUBST(SQLITE_LIBS)
PKG_CHECK_MODULES(GTK, gtk+-3.0)
AC_SUBST(GTK_CFLAGS)
AC_SUBST(GTK_LIBS)

And something like this in Makefile.am:

test_VALAFLAGS = --vapidir=@VAPIDIR@ --pkg gstreamer-0.10 --pkg glib-2.0 --pkg gio-2.0 --pkg posix --thread --pkg gstreamer-app-0.10 --pkg sqlite3 --pkg gtk+-3.0

test_CFLAGS = $(GIO_CFLAGS) $(GSTREAMER_CFLAGS) $(GSTREAMER_APP_CFLAGS) $(SQLITE_CFLAGS) $(GTK_CFLAGS)

test_LDFLAGS = $(GIO_LIBS) $(GSTREAMER_LIBS) $(GSTREAMER_APP_LIBS) $(SQLITE_LIBS) $(GTK_LIBS)