Fixed bug when using exported libs with no targets.

Added test for this case.