Posix threads

Posix threads

Uploaded a C-program that uses Posix threads, which compiles with cc & gcc
and runs fine on my own box.

MTL cc and gcc both accept several Posix calls except:
ParSort.c:(.text+0x538): undefined reference to `pthread_create'
ParSort.c:(.text+0x567): undefined reference to `pthread_join'
Baffling failure (and peculiar way to report a compilation error) ...
These two functions are core members in the Posix package - as I understand it.
Now what?

3 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

ddcc -

Don't you need to add the line "#include " (or something similar) in the source code? When I get the compilation errors that you are reporting, that's usually what's wrong. If you do have this line included, the path to the include files for your account are not set up right to find the pthread.h file.

Then, on the linking command, you add "-lpthread" to include the Pthreads library.

Your local environment may beincluding these automatically for you. It's been a while since I've had the chance to progam with Pthreads, but these are the things I find in some of my old codes and makefiles.


Yes, even with "#include " in the code cc-compilation on MTL requires:
cc -lpthread

I am still puzzled why the compiler found two other libraries but not
pthread.h and why the compiler did not complain on a host of other pthread
functions without the library directive ...

Leave a Comment

Please sign in to add a comment. Not a member? Join today