I want to make g++ linker(ld) search for libraries starting in the directory /usr/local/lib. How do I permanently add /usr/local/lib to the search path for the linker?
The problem is that I am trying to link the library libboost_program_options.a to my source. There are two copies of the library, one in /usr/lib/x86_64-linux-gnu/ and the other in /usr/local/lib. How do I make the linker first look in /usr/local/lib and pick that instead of the other one?
The output of ldconfig -v 2>/dev/null | grep -v ^$'\t' on my system:
/usr/lib/x86_64-linux-gnu/libfakeroot: /lib/i386-linux-gnu: /usr/lib/i386-linux-gnu: /usr/local/lib: /lib/x86_64-linux-gnu: /usr/lib/x86_64-linux-gnu: /usr/lib/x86_64-linux-gnu/mesa-egl: /usr/lib/nvidia-304: /usr/lib32/nvidia-304: /lib32: /usr/lib32: /lib: /usr/lib: /usr/lib/nvidia-304/tls: (hwcap: 0x8000000000000000) /usr/lib32/nvidia-304/tls: (hwcap: 0x8000000000000000) The output of ld --verbose | grep SEARCH_DIR | tr -s ' ;' \\012
SEARCH_DIR("=/usr/x86_64-linux-gnu/lib64") SEARCH_DIR("=/usr/local/lib/x86_64-linux-gnu") SEARCH_DIR("=/usr/local/lib64") SEARCH_DIR("=/lib/x86_64-linux-gnu") SEARCH_DIR("=/lib64") SEARCH_DIR("=/usr/lib/x86_64-linux-gnu") SEARCH_DIR("=/usr/lib64") SEARCH_DIR("=/usr/x86_64-linux-gnu/lib") SEARCH_DIR("=/usr/local/lib") SEARCH_DIR("=/lib") SEARCH_DIR("=/usr/lib")