Update build scripts to link libraries in the correct order.