Fix building errors on x86_64-w64-mingw32 due to wrong linking order.