Fix building with ninja

This PR fixes linking errors when building with ninja by using absolute path for external libraries.