title: Using a shared library linked with other shared libs
body: <p>I've compiled on OSX a shared library with some external dependences (<em>boost</em>, <em>OpenGL</em>):</p>
  
  <pre><code>g++ -dynamiclib -undefined suppress -flat_namespace -o "libMY_LIB.dylib" ./windowbase.o -lGL -lGLU -lGLUT -lboost_system -lboost_thread
  </code></pre>
  
  <p>No errors, <code>file libMY_LIB.dylib</code> results in <code>Mach-O 64-bit dynamically linked shared library x86_64</code>, and <code>otool -L libMY_LIB.dylib</code> outputs:</p>
  
  <pre><code>libPixelsGL.dylib (compatibility version 0.0.0, current version 0.0.0)
  /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib (compatibility version 1.0.0, current version 1.0.0)
  /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGLU.dylib (compatibility version 1.0.0, current version 1.0.0)
  /System/Library/Frameworks/GLUT.framework/Versions/A/GLUT (compatibility version 1.0.0, current version 1.0.0)
  libboost_system.dylib (compatibility version 0.0.0, current version 0.0.0)
  libboost_thread.dylib (compatibility version 0.0.0, current version 0.0.0)
  /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 52.0.0)
  /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 159.1.0)
  </code></pre>
  
  <p>Now I try to link an executable against <code>libMY_LIB.dylib</code>, using only functions in <code>MY_LIB.h</code> (and compiled in the lib):</p>
  
  <pre><code>g++ -L"/path/to/MY_LIB" -o "Program" ./main.o -lMY_LIB
  </code></pre>
  
  <p>but it fails, printing:</p>
  
  <pre><code>Undefined symbols for architecture x86_64:
  "boost::system::system_category()", referenced from:
      __static_initialization_and_destruction_0(int, int)in main.o
      boost::mutex::mutex()in main.o
      boost::mutex::lock()    in main.o
      boost::mutex::unlock()    in main.o
  "boost::system::generic_category()", referenced from:
      __static_initialization_and_destruction_0(int, int)in main.o
  "boost::thread::detach()", referenced from:
      boost::thread::~thread()in main.o
  ld: symbol(s) not found for architecture x86_64
  </code></pre>
  
  <p>Some explanation and/or help?</p>
  
  <p>Thanks!</p>
  
  <h1>EDIT</h1>
  
  <p>I tried to link the lib without <code>-undefined suppress -flat_namespace</code> flags and the executable with them, and the latter worked. Could please anyone tell me why? May it be <em>boost</em> libs I have were compiled with those flags?</p>
  
  <p>Renewed thanks!</p>