Re: POSIX thread question




Jack wrote:

I tried the following command, it works:
gcc -pthread -o threadapp threadapp.c

My book suggests the following:
gcc -pthread threadapp.c -o threadapp -lpthread

What is the different? Which on is better?

The first is better. The first will work whether or not there happens
to be a library called 'libpthread' that is needed for POSIX pthreads.
The second may fail or do the wrong thing if such a library does not
exist, is not needed, or does the wrong thing.

DS

.



Relevant Pages

  • Re: POSIX thread question
    ... is standard. ... current Linux platforms. ... gcc -pthread threadapp.c -o threadapp -lpthread ...
    (comp.os.linux.development.system)
  • Re: POSIX thread question
    ... gcc -pthread threadapp.c -o threadapp -lpthread ... (on GNU/Linux, anyway), so the latter version is just redundant. ...
    (comp.os.linux.development.system)
  • why dont MS provide a default compiler on XP?
    ... Linux has gcc and g++ ... DOS has quick basic ... How come Windows has got none? ... Jack ...
    (microsoft.public.windowsxp.general)