Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I want to build a program that use DBUS, using automake/autoconfig tools. But the make command always report an error "dbus/dbus-glib.h": No such file or directory.

My OS is ubuntu 10.10. And I installed both "dbus-1" and "dbus-glib-1". I check the generated Makefile and found both AM_CFLAGS and AM_LDFLAGS are empty.

Could somebody help? Many thanks!

Here is my code:

configure.ac:

AC_INIT([my-app], [0.1])
AC_PREREQ([2.59])
AM_INIT_AUTOMAKE([1.10 -Wall no-define])
AC_CONFIG_HEADERS([config.h])
AC_PROG_CC
AM_PROG_CC_C_O
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
DBUS_REQUIRED=1.3.1
DBUS_GLIB_REQUIRED=0.82
GLIB_REQUIRED=2.26.0

PKG_CHECK_MODULES(DBUS, [dbus-1 >= $DBUS_REQUIRED dbus-glib-1 >= $DBUS_GLIB_REQUIRED])
AC_SUBST(DBUS_CFLAGS)
AC_SUBST(DBUS_LIBS)

Makefile.am:

AUTOMAKE_OPTIONS = subdir-objects
ACLOCAL_AMFLAGS = ${ACLOCAL_FLAGS}
bin_PROGRAMS = my_app
my_app_SOURCES = src/my-app.c
AM_CFLAGS= @DBUS_CFLAGS@
AM_LDFLAGS= @DBUS_LIBS@
dist_noinst_SCRIPTS = autogen.sh

my-app.c

...
"#include" {{{<dbus/dbus-glib.h>}}}
...
share|improve this question

2 Answers 2

Did you run aclocal to bring in all the relevant definitions?

share|improve this answer
    
No. I run "autoreconf --force --install". Have I missed something? –  Amanda Mar 14 '11 at 7:53
    
No. autoreconf is the recommended way to do it, as it will run all the various components that are likely to be needed (automake, aclocal, libtoolize, autoconf, etc.) and run multiple times if needed to satisfy additional dependencies discovered by e.g. aclocal. –  geekosaur Mar 14 '11 at 7:56
    
Thanks for the information! But if"autoreconf" is enough, why AC_SUBST(DBUS_CFLAGS) and AC_SUBST(DBUS_LIBS) don't work? –  Amanda Mar 14 '11 at 8:00
    
I can use pkg-config to get the flags but they don't appear in my Makefile. $pkg-config --cflags dbus-glib-1 -pthread -I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include $pkg-config --libs dbus-glib-1 -pthread -L/lib -ldbus-glib-1 -ldbus-1 -lpthread -lgobject-2.0 -lgthread-2.0 -lrt -lglib-2.0 –  Amanda Mar 14 '11 at 8:04
    
Sorry, misread before. I don't actually know if autoreconf works the first time (note the -re-), as I've only needed to use it when working on existing packages. (Most of my development is in Perl or Haskell, neither of which is particularly autoconf-friendly.) –  geekosaur Mar 14 '11 at 8:06

I found the root cause. In configure.ac, I should have added DBUS C/LD flags before I call AC_CONFIG_FILES([Makefile]) and AC_OUTPUT. Then the AM_CFLAGS and AM_LDFLAGS in Makefile can get valid value.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.