help-make
[Top][All Lists]
Advanced

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

Re: problems depending on -l


From: Mike Shal
Subject: Re: problems depending on -l
Date: Fri, 2 Dec 2005 17:19:50 -0500

On 12/1/05, Karen Paffendorf <address@hidden> wrote:
> Hi,
>
> 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/libmy.so => not found
>
> if I gcc with the -lmy instead of the generated my_directory/libmy.so
> the problem goes away.
>
> ldd yields
>   libmy.so => ???/libmy.so
> 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 libmy.so'.
This tells the linker to use the 'libmy.so' name instead of the name
you pass on the command line (the 'my_directory/libmy.so' as you have
above). You shouldn't have to change the command line that then links
in libmy.so, only the command to build libmy.so.

>
> in the second on RH4 x86_64, -lm failed by explicately pulling in
> /usr/lib/libm.so, which was the wrong format.
> If the command included -lm, ldd showed it pointing to /lib64/libm.so.6
> 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
search:

  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,
-Mike




reply via email to

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