Robin Heggelund Hansen
Robin Heggelund Hansen

Reputation: 5006

Building Vala-project with autotools = "glib.h" not found

I’m trying to create my first vala and first autotools supported project. Everything actually works after following a tutorial online, but when gcc compiler kicks in to compile my program i get the error "glib.h not found".

first off, can’t just autotools use valac as a compiler instead of creating the .c files and then run gcc? (cause running valac directly works perfectly)

If I can’t configure autotools to just run valac instead of valac -c and then gcc, how would I go about solving this problem?

configure.ac:

AC_PREREQ([2.68])
AC_INIT([Scraps], [0.1], [Scraps])
AM_INIT_AUTOMAKE
AM_CONFIG_HEADER([config.h])
AC_PROG_CC
AM_PROG_VALAC
AC_CONFIG_FILES([Makefile
                 src/Makefile])
AC_OUTPUT

Makefile.am in ./src/:

scrapsdir=../
scraps_PROGRAMS=scraps
scraps_SOURCES=main.vala

Thanks!

Upvotes: 2

Views: 1037

Answers (1)

nemequ
nemequ

Reputation: 17492

As you said, autotools just runs valac -C and then run gcc. This is actually a good thing since everything is the same as with C. Any autotools documentation (including frustrated mailing list and stack overflow posts) you can find applies, so it's pretty easy to find an answer to anything just by googling the problem.

In your configure.ac you need something like:

PKG_CHECK_MODULES(GLIB, glib-2.0 gobject-2.0)
AC_SUBST(GLIB_LIBS)
AC_SUBST(GLIB_CFLAGS)

Then in your Makefile.am, something like:

scraps_LDFLAGS = $(GLIB_LIBS)
scraps_CFLAGS = $(GLIB_CFLAGS)

You can use http://gitorious.org/sqlheavy as an example. There are executables in examples/ and utils/, and a library in sqlheavy/, so it's fairly complete.

Upvotes: 4

Related Questions