title: Boost managed mapped files: not compatible between OSX and Linux?
body: <p>The code below creates and reads a file called <code>MyMappedFile</code>.  If I run the write code on Linux (Ubuntu 14.04), I can copy this file to other Linux machines and it reads fine. If I instead transfer it to OSX and attempt to run the read code on it, I get an error:</p>
  
  <pre><code>libc++abi.dylib: terminating with uncaught exception of type boost::interprocess::lock_exception: boost::interprocess::lock_exception
  </code></pre>
  
  <p>Conversely, files written on OSX are able to be read on OSX. But attempting to read them under Linux gives me a similar message:</p>
  
  <pre><code>terminate called after throwing an instance of 'boost::interprocess::lock_exception'
    what():  boost::interprocess::lock_exception
  </code></pre>
  
  <p>The resulting files are different.</p>
  
  <p>I'm writing with this code:</p>
  
  <pre><code>#include &lt;boost/interprocess/managed_mapped_file.hpp&gt;
  #include &lt;boost/interprocess/managed_shared_memory.hpp&gt;
  #include &lt;boost/interprocess/containers/string.hpp&gt;
  
  namespace bip=boost::interprocess;
  
  typedef bip::managed_shared_memory::segment_manager segment_manager_t;
  typedef bip::basic_string&lt;char, std::char_traits&lt;char&gt;, bip::allocator&lt;char, segment_manager_t&gt; &gt; shared_string;
  
  int main() {
    bip::managed_mapped_file *outfile = new bip::managed_mapped_file(bip::create_only, "MyMappedFile", 1000);
    outfile-&gt;find_or_construct&lt;shared_string&gt;("mystring")("bubza", outfile-&gt;get_segment_manager());
    outfile-&gt;flush();
  }
  </code></pre>
  
  <p>And reading with this:</p>
  
  <pre><code>#include &lt;boost/interprocess/managed_mapped_file.hpp&gt;
  #include &lt;boost/interprocess/managed_shared_memory.hpp&gt;
  #include &lt;boost/interprocess/containers/string.hpp&gt;
  
  namespace bip=boost::interprocess;
  
  typedef bip::managed_shared_memory::segment_manager segment_manager_t;
  typedef bip::basic_string&lt;char, std::char_traits&lt;char&gt;, bip::allocator&lt;char, segment_manager_t&gt; &gt; shared_string;
  
  int main() {
    bip::managed_mapped_file *infile = new bip::managed_mapped_file(bip::open_only, "MyMappedFile");
    shared_string *ptr = infile-&gt;find_or_construct&lt;shared_string&gt;("mystring")(infile-&gt;get_segment_manager());
    std::cout &lt;&lt; "I got " &lt;&lt; *ptr &lt;&lt; std::endl;
  }
  </code></pre>
  
  <p>Both machines are using GCC 4.8 (4.8.4 on Linux, 4.8.5 on OSX) and Boost 1.55.</p>
  
  <p>Why aren't the files compatible between these platforms? </p>
  
  <p>Please note that I'm talking about the <code>MyMappedFile</code> data file produced by the writing code. The executables produced by compiling the code are not being transferred between machines: the Linux code is compiled on a Linux machine, and the OSX code is compiled on the OSX machine.</p>