I have a pthreads program. I have to compile it with gcc -pthread in Linux (-pthreads is unrecognized option) and gcc -pthreads in Sun (-pthread is unrecognized option). Why the difference, since it's the same compiler? However, -lpthread works on both, but I heard this isn't always sufficient.
Asked
Active
Viewed 1.4k times
15
-
4It's not a function of the compiler, it's a function of the implementation of the library. – i_am_jorf Dec 09 '09 at 23:32
1 Answers
16
The Solaris -pthreads
and Linux -pthread
options do equivalent things. Apparently, gcc-4.x
series accepts -pthread
for Solaris as well.
You do want the -pthread
/-pthreads
option while compiling because it adds multithreading support in the preprocessor and the linker.

Alok Singhal
- 93,253
- 21
- 125
- 158