Since needed it for one of my research projects, I have created an offspin of the SharedMemory class in my FlexLib2 library (deprecated).
The SharedMemory class supports the creation of SharedMemory segments in the OpenMPI context. In the end you will have a shared memory segment on every machine, where the program is executed.
An example code is included. It compiles on gcc 4.8.4 on Ubuntu 14.04 with C++98 and C++11.
It also includes a Makefile and an example program. Checkout the
README for details. And: Have fun :-)
If you need some more info about how to deal with sys-V shared memory on a Linux system, I can recommend this article.