Operating System - HP-UX
1753776 Members
7136 Online
108799 Solutions
New Discussion юеВ

Re: Difference between using pthread and lpthread

 
SOLVED
Go to solution
Mani Subramanian
Occasional Contributor

Difference between using pthread and lpthread

When I compile a third party C application with a -lpthread in the LIB environment variable everything runs fine. But if I use just the -pthread in the LIB environment varible then I receive an error 68 at runtime.

Is there any difference between these libraries ? And any reason that HPUX ships both these ?
2 REPLIES 2
Laurent Menase
Honored Contributor

Re: Difference between using pthread and lpthread

Hi,

When compile with -lpthread it links with the libpthread lib,
when you compile with -pthread
it is cc -p -thread

So the it is not the right syntax.
Steve Steel
Honored Contributor
Solution

Re: Difference between using pthread and lpthread

Hi

From

http://www.aero.lr.tudelft.nl/facilities/manuals/ansic/threads.html#RN.CVT.NN586

Accessing the Pthreads Library
Pthreads (POSIX threads) refers to the Pthreads library of thread-management routines. For information on Pthread routines see the pthread(3t) man page.
To use the Pthread routines, your program must include the header file and the Pthreads library must be explicitly linked to your program. For example:

% cc -D_POSIX_C_SOURCE+199506L prog.c -lpthread

The -D_POSIX_C_SOURCE=199506L string specifies the appropriate POSIX revision level. In this case, the level is 199506L.


So -l tells the compiler to use pthread

It is not seperate

Steve STeel
If you want truly to understand something, try to change it. (Kurt Lewin)