Take the 2-minute tour ×

I have a functioning implementation of a MPI routine, which works fine. In the process of making this a hybrid between MPI and shared memory, I am using pthreads. This in turn proofed the need of pthread_barriers.

But when I try to compile my code with the mpicc compiler, it complains over pthread_barrier_t and other barrier commands. If I remove these, and keep other threading parts it compiles just fine.

This is the line of code I insert to break the compilation:

pthread_barrier_t* barrier;

And for compilation I use:

mpicc -lm myprogram.c -o myprogram

The error returned from the compiler is:


Where line 34 corresponds to what I wrote above.

[Edit] I am runnings this on Ubuntu 9.10, with the following gcc/mpicc compiler: gcc (Ubuntu 4.4.1-4ubuntu9) 4.4.1. [/Edit]

Does anyone know what could be wrong and how I can make it compile?


share|improve this question

2 Answers 2

pthread_barrier_t is part of the ADVANCED REALTIME THREAD option, so it might not be available on your system. BTW, if you pose such a specific question you should always mention OS, version number and things like that.

share|improve this answer
Ok. How do I find out, wheter this is a part of my system or not - and if not, how do I get support for it, and can I? I have added os and compiler version to my questing. Thanks! –  R Hoof Jul 3 '10 at 7:58
yes on ubuntu it should be in. do man pthread_barrier_wait to know the includes you need to specify etc –  Jens Gustedt Jul 3 '10 at 11:10
Ah, also you should give the error that gcc gives you. I vaguely remember that in some version you could not call a variable barrier because they had defined a macro by that name in some system includes. Perhaps rename it to something else just to see. –  Jens Gustedt Jul 3 '10 at 11:13
Tried with another barrier name :) --Ill look more into the man page... –  R Hoof Jul 3 '10 at 12:26

This means that pthread_barrier_t type is not in scope. Have you #include'd pthread.h?

share|improve this answer
Yes, or else I would not be able to compile all the other thread stuff... –  R Hoof Jul 3 '10 at 12:25
Can you provide some minimal example of the code which doesn't compile? Cause this one compiles perfectly: #include <pthread.h> int main () { pthread_barrier_t* barrier; return 0; } –  Roman Cheplyaka Jul 3 '10 at 13:16
Which compiler? and on what system? That wouldn't compile on my system using mpicc.. –  R Hoof Jul 4 '10 at 13:19
Wow. Does it produce the same error message? Does it compile using pure gcc, not mpicc? Mine is Debian Squeeze, gcc 4.4.4, and MPICH2 I also tried it on an Ubuntu 9.04 box, gcc 4.3.3 (but without mpicc), also ok. –  Roman Cheplyaka Jul 4 '10 at 19:01
Sorry Roman, I was a bit quick there. It does indeed compile - just missed the stdlib :) I will try to make a larger small scale example of my code, to see when it breaks... –  R Hoof Jul 5 '10 at 7:56

Your Answer


