Sun Studio 12: C++ User's Guide

A.2.55.1 Warnings

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 -mt and -lpthread options. The -mt option is necessary because libCrun (standard mode) and libC (compatibility mode) need libthread for a multithreaded application.

If you compile and link in separate steps and you compile with -mt, be sure to link with -mt, as shown in the following example, or you might get unexpected results.


example% CC -c -mt myprog.cc
example% CC -mt myprog.o

If you are mixing parallel Fortran objects with C++ objects, the link line must specify the -mt option.

C99 support is not available in compat mode (-compat=4).

See also

–xnolib, 10.5 Cache Member Variables, Multithreaded Programming Guide, Linker and Libraries Guide