| Home | Libraries | People | FAQ | More

## Chapter 9. Boost.Interprocess

### Ion Gaztanaga

Copyright © 2005 - 2010 Ion Gaztanaga

Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

## Introduction

Boost.Interprocess simplifies the use of common interprocess communication and synchronization mechanisms and offers a wide range of them:

- Shared memory.
- Memory-mapped files.
- Semaphores, mutexes, condition variables and upgradable mutex types to place them in shared memory and memory mapped files.
- Named versions of those synchronization objects, similar to UNIX/Windows sem_open/CreateSemaphore API.
- File locking.
- Relative pointers.
- Message queues.

Boost.Interprocess also offers higher-level interprocess mechanisms to allocate dynamically portions of a shared memory or a memory mapped file (in general, to allocate portions of a fixed size memory segment). Using these mechanisms, Boost.Interprocess offers useful tools to construct C++ objects, including STL-like containers, in shared memory and memory mapped files:

- Dynamic creation of anonymous and named objects in a shared memory or memory mapped file.
- STL-like containers compatible with shared memory/memory-mapped files.
- STL-like allocators ready for shared memory/memory-mapped files implementing several memory allocation patterns (like pooling).

### Building Boost.Interprocess

There is no need to compile Boost.Interprocess, since it's a header only library. Just include your Boost header directory in your compiler include path.

Boost.Interprocess depends on Boost.DateTime, which needs separate compilation. However, the subset used by Boost.Interprocess does not need any separate compilation so the user can define `BOOST_DATE_TIME_NO_LIB` to avoid Boost from trying to automatically link the Boost.DateTime.

In POSIX systems, Boost.Interprocess uses pthread system calls to implement classes like mutexes, condition variables, etc... In some operating systems, these POSIX calls are implemented in separate libraries that are not automatically linked by the compiler. For example, in some Linux systems POSIX pthread functions are implemented in `librt.a` library, so you might need to add that library when linking an executable or shared library that uses Boost.Interprocess. If you obtain linking errors related to those pthread functions, please revise your system's documentation to know which library implements them.

### Tested compilers

Boost.Interprocess has been tested in the following compilers/platforms:

- Visual 7.1 Windows XP
- Visual 8.0 Windows XP
- GCC 4.1.1 MinGW
- GCC 3.4.4 Cygwin
- Intel 9.1 Windows XP
- GCC 4.1.2 Linux
- GCC 3.4.3 Solaris 11
- GCC 4.0 MacOs 10.4.1

Last revised: November 10, 2010 at 00:44:31 GMT |