[maemo-developers] Undefined reference error

From: Dave Neary dneary at maemo.org
Date: Fri May 14 12:49:28 EEST 2010
Hi,

David King wrote:
> On 2010-05-14 11:13, David King <davidk at openismus.com> wrote:
>> Yes, if you are using libhal and libhal-storage through pkg-config with
>> autotools, then I guess that you have:
>>
>> PKG_CHECK_MODULES([HAL], [libhal libhal-storage])
>>
>> or similar in your configure.ac. If not, then you should add it.
> 
> Sorry, the line above should be:
> 
> PKG_CHECK_MODULES([HAL], [hal hal-storage])

Ah, the joys of package names vs pkgconfig modules...

The other way to do it with "normal" Makefileness is to get the CFLAGS
for HAL and HAL Storage with:

  pkg-config --cflags hal
  pkg-config --cflags hal-storage


and the LDFLAGS with

  pkg-config --libs hal
  pkg-config --libs hal-storage

In practice, in the Makefile, it'd probably look like this:

CFLAGS  = $(shell pkg-config --cflags hal hal-storage)
LDFLAGS = $(shell pkg-config --libs hal hal-storage)
OBJECTS = main.o

myprog: $(OBJECTS)
	cc $(CFLAGS) -o $(output) $(inputs) $(LDFLAGS)

%.o: %.c
	cc $(CFLAGS) -c $(input) -o $(output)

Cheers,
Dave.

-- 
maemo.org docsmaster
Email: dneary at maemo.org
Jabber: bolsh at jabber.org

More information about the maemo-developers mailing list