Improve shared library support for g++/clang.