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



Thanks, I fixed it...

2008/8/11 Mathias Hasselmann <mathias hasselmann gmx de>
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/

_______________________________________________
gtk-list mailing list
gtk-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-list




--
----------------------------------------------
┏━━━━━━━━━━━━━━━━━━━━━━━━┓
┃菩提本无树,明镜亦非台。本来无一物,何处惹尘埃。┃
┗━━━━━━━━━━━━━━━━━━━━━━━━┛


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