Re: So many warnning when I compiled base.c ?



Am Montag, den 11.08.2008, 17:47 +0800 schrieb Wu Yin:
> I wrote a Makefile for base.c, like following:
> +----------------------------------------------------------
> |# Makefile
> |
> |CFLAGS+=`pkg-config --cflags --libs gtk+-2.0`
> |
> |base:base.o
> | $(CC) $< -o $@ $(CFLAGS)
> +----------------------------------------------------------
> 
> I know "gcc -c" make this happen, but how to change Makefile to fix
> it?
> What the Makefile should be commonly?

You should not pass the linker flags to the compile stage.

CFLAGS += `pkg-config --cflags gtk+-2.0`
LDLIBS += `pkg-config --libs gtk+-2.0`

To link your object files you should use something like this:

base: base.o
	$(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@

"make -p | fgrep LINK.o" will show you how GNU make declares the
predefined "LINK.o" variable. Probably you want to use some more
sophisticated build system like autotools. Others believe that WAF or
cmake make some sense.

Ciao,
Mathias
-- 
Mathias Hasselmann <mathias hasselmann gmx de>
Openismus GmbH: http://www.openismus.com/
Personal Site: http://taschenorakel.de/

Attachment: signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]