I'm compiling a c++ program using g++ and ld. I have a .so library I want to be used during linking. However, a library of the same name exists in /usr/local/lib, and ld is choosing that library over the one I'm directly specifying. How can I fix this?
For the examples below, my library file is /my/dir/libfoo.so.0. Things I've tried that don't work:
- my g++ command is
g++ -g -Wall -o my_binary -L/my/dir -lfoo bar.cpp - adding
/my/dirto the beginning or end of my$PATHen` variable - adding
/my/dir/libfoo.so.0as an argument to g++
Thanks.