I need to define a (Open MPI) MPI_Datatype in a header file so that all other files that include it can find it. 

I also try to use extern to do decleration in .h file and then define them in .cpp file. 

But, I always get error: 

undefined reference 

It is not allowed in Open MPI ? 

Why ? 

Any help is really appreciated.