GCC and Clang warningless compilation in Gentoo.

Correct link order and only necessary libraries.