[build] some lib path ordering and a fix for older linuxes