Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gcc difference between -pthread and -pthreads?

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.

like image 568
Steven Avatar asked Dec 09 '09 23:12

Steven


People also ask

What is difference between GCC and CC?

CC is the name given to the UNIX Compiler Command. It is used as the default compiler command for your operating system and also is executable with the same command. GCC, on the other hand, is the GNU Compiler operating system.

What is G ++ and GCC?

The term gcc may still sometimes refer to the "GNU C Compiler" in the context of C programming. man gcc # GCC(1) GNU # # NAME # gcc - GNU project C and C++ compiler. However, g++ is the C++ compiler for the GNU Compiler Collection. Like gnat is the Ada compiler for gcc . see Using the GNU Compiler Collection (GCC)

Is GCC only for C?

GCC is an integrated distribution of compilers for several major programming languages. These languages currently include C, C++, Objective-C, Objective-C++, Java, Fortran, and Ada.


1 Answers

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.

like image 81
Alok Singhal Avatar answered Oct 21 '22 13:10

Alok Singhal