As the GCC manual says, LIBRARY_PATH
is the correct environment variable to add directories to the library search path.
If you add -v
to the g++
command you should see the LIBRARY_PATH
that it uses, and you should see it includes the directory you have specified, and that it gets added to the collect2
command as -L
, but you will see it gets added after the standard directories such as -L/usr/lib
etc.
I don’t know any way to make the directories in LIBRARY_PATH
come first, I think you have to use -L
for that.