title: C++ boost libraries shared_memory_object undefined reference to 'shm_open'
body: <p>I tried to compile the following code on ubuntu 11.04:</p>
  
  <pre><code>#include &lt;boost/interprocess/shared_memory_object.hpp&gt; 
  #include &lt;iostream&gt; 
  
  int main() 
  { 
    boost::interprocess::shared_memory_object shdmem(boost::interprocess::open_or_create, "Highscore", boost::interprocess::read_write); 
    shdmem.truncate(1024); 
    std::cout &lt;&lt; shdmem.get_name() &lt;&lt; std::endl; 
    boost::interprocess::offset_t size; 
    if (shdmem.get_size(size)) 
      std::cout &lt;&lt; size &lt;&lt; std::endl; 
  } 
  </code></pre>
  
  <p>only to get the following errors:</p>
  
  <pre><code>/tmp/cc786obC.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;)':
  shared_memory.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'
  shared_memory.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'
  shared_memory.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'
  shared_memory.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'
  collect2: ld returned 1 exit status
  </code></pre>
  
  <p>Command I used to compile the file: g++ -o shared  shared.cpp</p>
  
  <p>Command I used to install the boost libraries: sudo apt-get install libboost-dev libboost-doc</p>