Clearing/resetting g++/ld linker path for each -l

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
 
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.

Sorry, I didn't mean to repost this here. A bad case of copy and paste
disease...

Apologies,
Andy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top