title: Linker error compiling with boost::interprocess
body: <p>I have written a small program that writes a boost::interprocess::container string into a shared memory and another one to read from it.</p>
  
  <p>I am getting the follow linker errors:</p>
  
  <pre><code>g++ SharedMemTest.cpp -L /usr/lib/x86_64-linux-gnu/librt.a
  /tmp/cc5v7WKj.o: In function `boost::interprocess::detail::mutexattr_wrapper::mutexattr_wrapper(bool)':
  SharedMemTest.cpp:(.text._ZN5boost12interprocess6detail17mutexattr_wrapperC2Eb[_ZN5boost12interprocess6detail17mutexattr_wrapperC5Eb]+0x1c): undefined reference to `pthread_mutexattr_init'
  SharedMemTest.cpp:(.text._ZN5boost12interprocess6detail17mutexattr_wrapperC2Eb[_ZN5boost12interprocess6detail17mutexattr_wrapperC5Eb]+0x31): undefined reference to `pthread_mutexattr_setpshared'
  SharedMemTest.cpp:(.text._ZN5boost12interprocess6detail17mutexattr_wrapperC2Eb[_ZN5boost12interprocess6detail17mutexattr_wrapperC5Eb]+0x4c): undefined reference to `pthread_mutexattr_settype'
  /tmp/cc5v7WKj.o: In function `boost::interprocess::detail::mutexattr_wrapper::~mutexattr_wrapper()':
  SharedMemTest.cpp:(.text._ZN5boost12interprocess6detail17mutexattr_wrapperD2Ev[_ZN5boost12interprocess6detail17mutexattr_wrapperD5Ev]+0x14): undefined reference to `pthread_mutexattr_destroy'
  /tmp/cc5v7WKj.o: In function `boost::interprocess::shared_memory_object::priv_open_or_create(boost::interprocess::detail::create_enum_t, char const*, boost::interprocess::mode_t, boost::interprocess::permissions const&amp;)':
  SharedMemTest.cpp:(.text._ZN5boost12interprocess20shared_memory_object19priv_open_or_createENS0_6detail13create_enum_tEPKcNS0_6mode_tERKNS0_11permissionsE[boost::interprocess::shared_memory_object::priv_open_or_create(boost::interprocess::detail::create_enum_t, char const*, boost::interprocess::mode_t, boost::interprocess::permissions const&amp;)]+0xe0): undefined reference to `shm_open'
  SharedMemTest.cpp:(.text._ZN5boost12interprocess20shared_memory_object19priv_open_or_createENS0_6detail13create_enum_tEPKcNS0_6mode_tERKNS0_11permissionsE[boost::interprocess::shared_memory_object::priv_open_or_create(boost::interprocess::detail::create_enum_t, char const*, boost::interprocess::mode_t, boost::interprocess::permissions const&amp;)]+0x116): undefined reference to `shm_open'
  SharedMemTest.cpp:(.text._ZN5boost12interprocess20shared_memory_object19priv_open_or_createENS0_6detail13create_enum_tEPKcNS0_6mode_tERKNS0_11permissionsE[boost::interprocess::shared_memory_object::priv_open_or_create(boost::interprocess::detail::create_enum_t, char const*, boost::interprocess::mode_t, boost::interprocess::permissions const&amp;)]+0x16c): undefined reference to `shm_open'
  SharedMemTest.cpp:(.text._ZN5boost12interprocess20shared_memory_object19priv_open_or_createENS0_6detail13create_enum_tEPKcNS0_6mode_tERKNS0_11permissionsE[boost::interprocess::shared_memory_object::priv_open_or_create(boost::interprocess::detail::create_enum_t, char const*, boost::interprocess::mode_t, boost::interprocess::permissions const&amp;)]+0x1c0): undefined reference to `shm_open'
  /tmp/cc5v7WKj.o: In function `boost::interprocess::shared_memory_object::remove(char const*)':
  SharedMemTest.cpp:(.text._ZN5boost12interprocess20shared_memory_object6removeEPKc[boost::interprocess::shared_memory_object::remove(char const*)]+0x40): undefined reference to `shm_unlink'
  </code></pre>
  
  <p>I have also tried to link with the following:</p>
  
  <pre><code>g++ -c SharedMemTest.cpp
  g++ -L /usr/lib/x86_64-linux-gnu/librt.a SharedMemTest.o -o SharedMemTest
  </code></pre>
  
  <p>But none of these commands are working. Could someone please tell me how I can get this simple example to compile?</p>