Posix threads

Posix threads

Portrait de ddcc

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 nouveau(x)
Dernière contribution
Reportez-vous à notre Notice d'optimisation pour plus d'informations sur les choix et l'optimisation des performances dans les produits logiciels Intel.
Portrait de Clay Breshears (Intel)

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.

--clay

Portrait de ddcc

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 ...

Connectez-vous pour laisser un commentaire.