How do I use POSIX threads with gcc 2.7.x?

How do I use POSIX threads with gcc 2.7.x? From: David Edelsohn


The code generated by GCC is compatible with threads, but gcc-2.7
was released so long ago that it did not provide an option to perform
the extra link steps necessary to support threads:

1) Compile all source files with "-D_THREAD_SAFE" macro defined.
2) Link with "-L/usr/lib/threads -lpthreads -lc_r /usr/lib/libc.a"
to obtain the pthreads support
and add "-nostartfiles /usr/lib/crt0_r.o" to the beginning of the
link command line (using gcc to link!) to initialize threads.



Home FAQ