Reading through the gcc manual, I believe the following two statements are true:
Library search paths specified on the command line are searched before "default" paths (which I assume means stuff in the LIBRARY_PATH environment variable)
Shared libraries will be linked in preference to static libraries (in the absence of flags saying to do otherwise)
But which of these two dominates? For example, if I type
gcc myprog.cpp -o myprog -Lmypath -lmylibrary
and in mypath there is the static library "libmylibrary.a", and in some place specified in LIBRARY_PATH there is a shared library "libmylibrary.so", which of these libraries will get used? My guess would be that the static library will get used (i.e. (1) dominates) but I am seeing some funny compile errors that make me question this guess, so I wanted to make sure...