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?
Karen
# Simple make file to reproduce "knowing how to make library" failure
#$ gmake -f pre.mk whatever
#gmake: *** No rule to to make target `-lmy', needed by `whatever'. Stop.
#$ mkdir exists
#$ gmake -f pre.mk whatever DIR=exists
#touch exists/libmy.so
#exists/libmy.so
#$
DIR=not_exists
$(DIR):
mkdir -p $(DIR)
$(DIR)/libmy.so:
touch $@
whatever: -lmy
@echo $^
vpath libmy% $(DIR)
Mike Shal wrote:
On 12/1/05, Karen Paffendorf <[EMAIL PROTECTED]> 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
_______________________________________________
Help-make mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-make