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

A

Andy Buckley

Hi,

This is really a g++/gcc/ld issue rather than C++ specifically -
please redirect me to another newsgroup if there's a more appropriate
place to ask! Also, I thought I'd posted this topic yesterday but on
looking I can't find it. Either something went wrong with the my
system or I just forgot to press "Submit"... sorry if this question
does end up appearing twice.

My problem is that if 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 interpreted. 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
 
V

Victor Bazarov

Andy said:
Hi,

This is really a g++/gcc/ld issue rather than C++ specifically -
please redirect me to another newsgroup if there's a more appropriate
place to ask! [..]

Here you go: gnu.g++.help.

V
 

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

Forum statistics

Threads
473,968
Messages
2,570,150
Members
46,697
Latest member
AugustNabo

Latest Threads

Top