Skip to main content
edited title
Link
Rakete1111
  • 49.5k
  • 19
  • 133
  • 173

g++: how How to specify preference of library path?

deleted 11 characters in body
Source Link
Ciro Santilli OurBigBook.com
  • 392.6k
  • 120
  • 1.3k
  • 1.1k

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/dir to the beginning or end of my $PATH en` variable
  • adding /my/dir/libfoo.so.0 as an argument to g++

Thanks.

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/dir to the beginning or end of my $PATH en` variable
  • adding /my/dir/libfoo.so.0 as an argument to g++

Thanks.

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/dir to the beginning or end of my $PATH en` variable
  • adding /my/dir/libfoo.so.0 as an argument to g++
popular question might deserve better formatting (code sections)
Source Link

I'm compiling a c++ program using g++g++ and ldld. I have a .so.so library I want to be used during linking. However, a library of the same name exists in /usr/local/lib/usr/local/lib, and ldld 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/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"g++ -g -Wall -o my_binary -L/my/dir -lfoo bar.cpp
  • adding /my/dir/my/dir to the beginning or end of my $PATH env$PATH en` variable
  • adding /my/dir/libfoo.so.0/my/dir/libfoo.so.0 as an argument to g++

Thanks.

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/dir to the beginning or end of my $PATH env variable
  • adding /my/dir/libfoo.so.0 as an argument to g++

Thanks.

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/dir to the beginning or end of my $PATH en` variable
  • adding /my/dir/libfoo.so.0 as an argument to g++

Thanks.

Source Link
Loading