Re: POSIX thread question



On 29 Aug 2006 08:17:52 -0700, Jack <junw2000@xxxxxxxxx> 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?

There is really no difference. -pthread implies -lpthread
(on GNU/Linux, anyway), so the latter version is just redundant.

--
Mikko Rauhala - mjr@xxxxxx - <URL:http://www.iki.fi/mjr/>
Transhumanist - WTA member - <URL:http://www.transhumanism.org/>
Singularitarian - SIAI supporter - <URL:http://www.singinst.org/>

.



Relevant Pages

  • Re: POSIX thread question
    ... Jack wrote: ... gcc -pthread threadapp.c -o threadapp -lpthread ... The second may fail or do the wrong thing if such a library does not ...
    (comp.os.linux.development.system)
  • Re: POSIX thread question
    ... is standard. ... current Linux platforms. ... gcc -pthread threadapp.c -o threadapp -lpthread ...
    (comp.os.linux.development.system)
  • Re: Ada exception block does NOT work?
    ... No I tested it on GNU/Linux, ... GCC 4.0.1 for GNU/Linux does not have this bug. ... Svesse, your user agent string says you're running ... Did you test this on Windows? ...
    (comp.lang.ada)
  • Re: getopt_long problem
    ... > In witch I use getopt_long function... ... > when i try to link the program with gcc -o result main.o ... features from your code and then linking should work fine. ... Printing on GNU/Linux? ...
    (comp.lang.c)
  • Re: [PATCH] Avoid namespace pollution in
    ... config.h is always implicit included using -include option to gcc, ... is redundant and the correct patch would be to get rid of it. ...
    (Linux-Kernel)