This option accumulates instead of overrides.
It is always safer to put –lx after the list of sources and objects to insure that libraries are searched in the correct order.
To ensure proper library linking order, you must use -mt, rather than -lthread, to link with libthread.
–Ldir, -mt, 11.4.8 An Example Application, and Tools.h++ Class Library Reference