Re-commit of r238201 with fix for building with shared libraries.