Improve error reporting in build_library.
Merge pull request #1079 from juj/build_library_error_report

Improve error reporting in build_library.