A
Andy Buckley
Hi,
I'd like to know if it's possible to clear the ld library search path
within a single linker call. Specificlly, the problem is that I have
two libraries A and B, and there's a version of each in two include
paths, say /usr/lib and/usr/local/lib. So we've got /usr/lib/libA.so, /
usr/lib/libB.so, /usr/local/lib/libA.so and /usr/local/lib/libB.so.
Now I want to link against the version of library A from /usr/lib and
the version of B from /usr/local/lib. Unfortunately this command line
doesn't work:
g++ ... -L/usr/lib -lA -L/usr/local/lib -lB
because /usr/lib is still the first location in the library search
path when -lB gets used. In the general case I won't know so much
about the exact library paths, so let's assume for now that I can't
just use absolute paths to each library. Is there maybe a way that I
can reset or clear the library search path in between each -l, e.g.
g++ ... -L/usr/lib -lA -reset-libpath -L/usr/local/lib -lB
? I'm using autotools and libtool if that's any help. If there's no
way of doing that, is there any other technique which will avoid me
needing to rewrite a large chunk of our build system's m4 macros to
work out absolute paths for every library?
Thanks!
Andy
I'd like to know if it's possible to clear the ld library search path
within a single linker call. Specificlly, the problem is that I have
two libraries A and B, and there's a version of each in two include
paths, say /usr/lib and/usr/local/lib. So we've got /usr/lib/libA.so, /
usr/lib/libB.so, /usr/local/lib/libA.so and /usr/local/lib/libB.so.
Now I want to link against the version of library A from /usr/lib and
the version of B from /usr/local/lib. Unfortunately this command line
doesn't work:
g++ ... -L/usr/lib -lA -L/usr/local/lib -lB
because /usr/lib is still the first location in the library search
path when -lB gets used. In the general case I won't know so much
about the exact library paths, so let's assume for now that I can't
just use absolute paths to each library. Is there maybe a way that I
can reset or clear the library search path in between each -l, e.g.
g++ ... -L/usr/lib -lA -reset-libpath -L/usr/local/lib -lB
? I'm using autotools and libtool if that's any help. If there's no
way of doing that, is there any other technique which will avoid me
needing to rewrite a large chunk of our build system's m4 macros to
work out absolute paths for every library?
Thanks!
Andy