This content has been marked as final. Show 2 replies
Solaris 10 incorporated the threads library into libc, so you no longer need -lpthread. -mt is equivalent to -D_REENTRANT. So you just need -mt.
Releases of Studio generally support multiple versions of Solaris, so the advice in the C++ Users Guide provides guidance on what will work on all supported platforms.
When compiling with CC, or when linking an executable program using CC, you need -mt but not -lthread.
When linking a shared library, no libraries are linked by default. You need to list explicitly every library that the shared library needs. In that case, you would need to add -lthread.
If you link explicitly using ld instead of CC you must list all needed libraries. We strongly recommend against linking C++ programs using ld, because the command line needed depends on the CC options, and is difficult to get it right.
For Posix threads, in general you need to add -lpthread, since pthreads are not the default.
But as Darryl points out, on Solaris 10 and 11 the thread and pthread libraries are part of libc, so you don't need to list them.