title: Dynamic Linking of Shared Libraries with Dependencies
body: <p>Is there a way to dynamically link shared libraries that have dependencies?</p>
  
  <p>For example, I have two libraries, libA.so and libB.so. libB.so calls functions defined in libA.so.</p>
  
  <p>In my main program, I wish to load the two libraries with dlopen. However, if I try:</p>
  
  <pre><code>dlopen(libA.so);
  dlopen(libB.so);
  </code></pre>
  
  <p>Then the second dlopen will fail as libB has unrecognized symbols.</p>
  
  <p>I can think of a few workarounds such as building all the object files into a single shared library, or to have libB.so call dlopen on libA.so, but that's extra work.</p>
  
  <p>I guess the way I'm imagining this to work is like in the case of kernel modules where you can use "EXPORT_SYMBOL()" to allow other modules to call functions defined in a previously loaded module.</p>
  
  <p>Can something similar be done with shared libraries? Or will I have to use my workarounds?</p>