[Top][All Lists]

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

Re: problems depending on -l

From: Karen Paffendorf
Subject: Re: problems depending on -l
Date: Mon, 05 Dec 2005 13:57:39 -0800
User-agent: Mozilla Thunderbird 0.8 (Windows/20040913)

Hi Mike,

Thanks - getting closer.

Adding -Wl,-soname=$(@F) when building that target in a directory generated the ldd results that seem to work at runtime. (Still need a resolution of the problem that I reported to the bug team: The library only builds if the directory exists. It does not trigger the rule that builds the directory the library get built in. See below for code to reproduce what I perceive as a bug.)

Unfortunately modifying the vpath did not change which libm got chosen, so the error continued as before.
Should I report this as a bug?


# Simple make file to reproduce "knowing how to make library" failure

#$ gmake -f whatever
#gmake: *** No rule to to make target `-lmy', needed by `whatever'.  Stop.
#$ mkdir exists
#$ gmake -f whatever DIR=exists
#touch exists/


        mkdir -p $(DIR)

        touch $@

whatever: -lmy
        @echo $^

vpath libmy% $(DIR)

Mike Shal wrote:

On 12/1/05, Karen Paffendorf <address@hidden> wrote:

I seem to be having two different problems with putting -l... as a
dependency and linking $^ with gcc.

In the first, I am building my own library in a subdirectory
(using a "vpath libmy% my_directory" and "executable: -lmy"
and having runtime problems because the library exists in a different place.

ldd yields
 my_directory/ => not found

if I gcc with the -lmy instead of the generated my_directory/
the problem goes away.

ldd yields => ???/
and the executable runs.

Am I missing something in the compiler or ldd conf?

I believe in this case you can build the library using the -soname
flag to the linker. I think you'd want to pass in '-soname'.
This tells the linker to use the '' name instead of the name
you pass on the command line (the 'my_directory/' as you have
above). You shouldn't have to change the command line that then links
in, only the command to build

in the second on RH4 x86_64, -lm failed by explicately pulling in
/usr/lib/, which was the wrong format.
If the command included -lm, ldd showed it pointing to /lib64/
It worked fine in my other build environments.

Not sure on this, I'm guessing it's because make's search algorithm
differs from your compiler's. According to the make manual, make will

 directories specified by matching `vpath' search paths
 and the `VPATH' search path, and then in the directories `/lib',
 `/usr/lib', and `PREFIX/lib' (normally `/usr/local/lib'...

So maybe you just need to add /lib64 to VPATH so make knows about it?

Hope this helps,

reply via email to

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