I advice you to move "lnk << linkoptions;" before "PutConsole("Linking...");", with adding a space in preceding string " -Wl,--end-group ".
I advice you to move "lnk << linkoptions;" before "PutConsole("Linking...");", with adding a space in preceding string " -Wl,--end-group ".