Sun Studio 12: C User's Guide

B.2.46 -mt

Compile and link for multithreaded code.

This option passes -D_REENTRANT to the preprocessor and passes -lthread in the correct order to ld.

The -mt option is required if the application or libraries are multithreaded.

To ensure proper library linking order, you must use this option, rather than -lthread, to link with libthread.

If you are using POSIX threads, you must link with the options -mt -lpthread. The -mt option is necessary because libC and libCrun need libthread for a multithreaded application.

Modules that are compiled with -mt must also be linked with -mt. For a complete list of compiler options that must be specified at both compile time and at link time, see A.1.2 Compile-Time and Link-Time Options.

If you compile one translation unit with -mt, compile all units of the program with -mt.

See also B.2.113 -xnolib.