Various build & linking fixes.

Signed-off-by: Peter Soetens <peter@thesourceworks.com>