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

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

 



Thanks, I fixed it...

2008/8/11 Mathias Hasselmann <mathias.hasselmann@xxxxxx>
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@xxxxxx>
Openismus GmbH: http://www.openismus.com/
Personal Site: http://taschenorakel.de/

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




--
----------------------------------------------
┏━━━━━━━━━━━━━━━━━━━━━━━━┓
┃菩提本无树,明镜亦非台。本来无一物,何处惹尘埃。┃
┗━━━━━━━━━━━━━━━━━━━━━━━━┛
_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list

[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux