You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by Martin Kalen <ma...@todaysystems.com.au> on 2001/10/18 02:48:28 UTC

Re: Multithreading

  ----- Original Message ----- 
  From: suresh 


  Operating system : RH 7.1
  compiler: gcc2.95.2

  I have a multithreaded application with runs fine in windows when i port the
  code to linux iam having problems.
  Do i have to link special libraries to make it multithreaded in linux (Like
  Multithreaded Option In VC++ IDE) .
The definition _POSIX_C_SOURCE should be set to 199506L or higher for the IEEE 1003.1c-1995 standard (i.e. POSIX threads the way you would probably expect them to behave).

You should also define the symbol _REENTRANT (which has an alias _THREAD_SAFE for compatibility with other systems) to select re-entrant functions from the C-library.

Typically, this would mean that in your Makefile you extend CFLAGS to something like:
CFLAGS    = (your old stuff here) -D_POSIX_C_SOURCE=199506L -D_REENTRANT

(Check /usr/include/features.h for some nitty gritty...)

You must also link with the thread library by adding "-lpthread" to your link command, but I assume you already do this - since you would otherwise get heaps of errors about undefined pthread* symbols.

Good luck,
 Martin