title: Manipulating the symbol resolution order for dynamic library loading
body: <p>I'm trying to manipulate (or at least better understand) the symbol resolution order when loading dynamic libraries at runtime.  In my example here I am using dlopen on a Linux OS.</p>
  
  <p>I'm trying to get the dynamically loaded interpreter library "libmyint.so" to link with the function "message_from_library" in the shared object library "libmylib.so" and not with the "libmylib.a"  that is linked into the application "myapp" which is what I currently have.</p>
  
  <p><a href="http://www.filedropper.com/codetar" rel="nofollow" title="code.tar.gz">code.tar.gz</a></p>
  
  <p><a href="http://www.filedropper.com/codetar" rel="nofollow" title="code.tar.gz">1</a> contains an archive of a simple example to understand this better.  The following is the instructions on how to build the example and run it.</p>
  
  <p>Instructions to build:</p>
  
  <pre><code>tar xzf code.tar.gz
  mkdir app-build int-build lib-build
  cd lib-build
  cmake ../lib
  make
  cd ../int-build
  cmake ../int
  make
  cd ../app-build
  cmake ../app
  make
  
  ./myapp
  </code></pre>
  
  <p>Actual output:</p>
  
  <pre><code>Call to statically linked interpreter function.
  This message is from a static interpreter library object.
  This message is from a static library object.
  Call to dynamically loaded function in interpreter library.
  This message is from a *shared* interpreter library object.
  This message is from a static library object.
  </code></pre>
  
  <p>Desired output:</p>
  
  <pre><code>Call to statically linked interpreter function.
  This message is from a static interpreter library object.
  This message is from a static library object.
  Call to dynamically loaded function in interpreter library.
  This message is from a *shared* interpreter library object.
  This message is from a *shared* library object.
  </code></pre>
  
  <p>I'm hoping someone can tell me how to get the desired output in this example.</p>
  
  <p>Thanks.</p>