[Top][All Lists]

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

Re: Make: puzzeling make behaviour ?

From: Henrik Carlqvist
Subject: Re: Make: puzzeling make behaviour ?
Date: Mon, 19 Feb 2007 08:31:59 +0100
User-agent: Pan/0.14.2 (This is not a psychotic episode. It's a cleansing moment of clarity.)

B Thomas <> wrote:
> I am trying to compile a simple program that use a static library in
> ~/lib with corresponding include file in ~/include. My LD_LIBRARY_PATH
> includes ~/lib.

I don't think that gcc cares about LD_LIBRARY_PATH when it searches for
static libs. LD_LIBRARY_PATH is used by to find dynamics libs.

> Here is the Makefile 

> GLTKPATH=/home/bt
> GLTKLIB=-L$(GLTKPATH)/lib -lgltk

So you have pointed out where to search for libraries and header files,
you have also told gcc to search for a library named libgltk.a.

> However the compilation fails even though all the paths in this makefile
> are correct, gcc can not find symbols defined in libgltk.a . 

Is libgltk.a really a static library? What does 

nm /home/bt/lib/libgltk.a


ar t /home/bt/lib/libgltk.a


> Also if I try to change the gcc command line and then run make again it 
> does not run the changed version of the command !!!

That is because it has never run your command. Instead make has been using
a built in command in lack of any useful rule:

> SRCFILES=$(wildcard *.c)
> OBJFILES=$(patsubst %.c,%.o, $(SRCFILES))
> PROGRAMS=$(patsubst %.c,%, $(SRCFILES))

> build:  $(PROGRAMS)
>       $(CC) $(CFLAGS) $(LDFLAGS) -o "$@" "$<"

Say that you have a single file called "myfile.c". If so, above you have a
rule that expands to:

build: myfile
        $(CC) $(CFLAGS) $(LDFLAGS) -o build myfile

I don't think the above rule was what you intended. Instead of using the
rule above make will do its best to find a way to build "myfile" as that
is needed by "build". This could also explain your problem with the static
library, are the flags to find the library used when gcc tries to compile
your file?

regards Henrik
The address in the header is only to prevent spam. My real address is:
hc1(at) Examples of addresses which go to spammers:
root@localhost postmaster@localhost

reply via email to

[Prev in Thread] Current Thread [Next in Thread]