You can do this by executing the following command:
ld --verbose | grep SEARCH_DIR | tr -s ' ;' \012
gcc passes a few extra -L paths to the linker, which you can list with the following command:
gcc -print-search-dirs | sed '/^lib/b 1;d;:1;s,/[^/.][^/]*/../,/,;t 1;s,:[^=]*=,:;,;s,;,; ,g' | tr ; \012
The answers suggesting to use ld.so.conf and ldconfig are not correct because they refer to the paths searched by the runtime dynamic linker (i.e. whenever a program is executed), which is not the same as the path searched by ld (i.e. whenever a program is linked).
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…