Merge the shared library build fixes into trunk