Boost logo

Boost Users :

Subject: [Boost-users] [thread] Compiling libraries compatible with Boost.Thread using g++ on Linux
From: Jorge Moraleda (moraleda_at_[hidden])
Date: 2010-05-12 19:49:43


Dear Boost.Thread experts,

I wrote some libraries that are not multithreaded, but
are supposed to be reentrant. I am compiling them from source.

When I produce an executable that links these static libraries and invokes
functions from these libraries from multiple threads via
Boost.Threads, valgrind drd reports some race conditions in what
appears to be straight forward memory access allocated with calloc. To
be clear: the library function allocates some memory with calloc and
later releases it. This memory is local to the function.

I am wondering if I need to use any especial compiler flags when
compiling the static libraries to make sure they are reentrant and
compatible with Boost.Thread. In particular should I use or not use
"-pthread" when compiling the libraries? Should I use "-pthread" when
compiling and linking the final executable?

I use gcc version 4.4.4 (Debian 4.4.4-1) and boost 1.42 (compiled from
source because I am using Boost.Log).

Thank you.

Jorge Moraleda


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net