Re: reentrant library functions



Mike wrote:
On Sep 16, 10:01 pm, David Schwartz <dav...@xxxxxxxxxxxxx> wrote:

First, to correct one error in your post, '-lpthread' is a linker flag
and has no effect on compiling. You probably mean '-pthread', which on
many platforms (including Linux), selects compiling and linking for
pthreads support.


I do not quite understand.
My functions use semaphores to ensure that any threaded access
is exclusive (sem_wait() and sem_post()). I need the '-lpthread' flag,
or else I get linker errors.

He's saying that it's more correct to specify "-pthread" rather than "-lpthread".

Technically "-lpthread" is only a linker flag, not a compiler flag. Some platforms also require a compiler flag such as -D_REENTRANT, and if you build/link with "-pthread" it will do the right thing.

Chris
.



Relevant Pages

  • Re: [OT] Why code completion and early error checking are needed
    ... circumstances in which the required language feature can be compromised. ... example of compiling code that does not use the C/C++ preprocessor. ... and this code is actually the same on all platforms. ... system-calls and memory-allocations from the system are invoked). ...
    (comp.lang.cpp)
  • [PATCH] Re: Building on platforms other than Linux
    ... >> platforms? ... >The userbase for building kernels are only increasing and there ... >> I am currently compiling on MacOSX and this, ... Attached is a patch to avoid using shared libraries in the build system. ...
    (Linux-Kernel)
  • he deamon runs fine on 64-bit machine, BUT CRASHES ON 32-bit MACHINE!!!
    ... I am in process of porting Linux project to 64-bit systems. ... needs to support 64-bit as well as 32-bit platforms. ... I am facing some issues while porting my daemon, ... Developing & compiling the daemon on 64-bit ...
    (comp.os.linux.development.system)
  • Re: Apples poor positioning for the age *after* x86
    ... >> And this recompiling is bad... ... I've been compiling this Gentoo install for the last 30-something ... IF, that is, Microsoft let it work on different platforms. ... And that assumes that the .net code works on different platforms. ...
    (comp.sys.mac.advocacy)
  • The deamon runs fine on 64-bit machine, BUT CRASHES ON 32-bit MACHINE!!! Please advice
    ... I am in process of porting Linux project to 64-bit systems. ... needs to support 64-bit as well as 32-bit platforms. ... I am facing some issues while porting my daemon, ... Developing & compiling the daemon on 64-bit ...
    (comp.os.linux.development.apps)