Attempt to solve linking against all dependencies problem on Linux

(similar to https://www.nsnam.org/bugzilla/show_bug.cgi?id=1292)