title: Application linking 2 versions of same library due to dependencies
body: <p>I'm having problems with a library (libpng) which my application is dynamically linking on Linux. </p>
  
  <p>The libpng version I'm using is libpng15. Since my application is also linking DI-GUY, which is linking libpng3, these 2 version clash. With "clash" I mean that the linker (ldd) picks the libpng3 instead of libpng15.</p>
  
  <p>If I look at the ldd output, both libpng15 and libpng3 are listed. The order is the following:</p>
  
  <pre><code>    libpng.so.3 =&gt; ../lib/libpng.so.3 (0x00007f4bccdff000)
      libpng15.so.15 =&gt; ../lib/libpng15.so.15 (0x00007f4bc5d1b000)
  </code></pre>
  
  <p>In CMake, I make sure I link against 15 specifically:</p>
  
  <pre><code>add_library(PNG::Shared SHARED IMPORTED)
      set_target_properties(PNG::Shared PROPERTIES
      IMPORTED_LOCATION ${_IMPORT_PREFIX}/lib/libpng15.so.15.4.0
      INTERFACE_INCLUDE_DIRECTORIES ${_IMPORT_PREFIX}/include
      INTERFACE_LINK_LIBRARIES z
  )
  </code></pre>
  
  <p>From my understanding, the application should take libpng15, but since libpng.so.3 is further up in the ldd than the 15 version, the linker picks the libpng.so.3 instead. </p>
  
  <p>How can I please force my application to use the libpng15.so.15, and the DI-GUY lib will use the libpng.so.3. Since I cannot recompile DI-GUY, I'm stuck with libpng.so.3 being also linked, but it should not get confused with the 15 version... </p>
  
  <p>What I don't understand is why the libpng.so.3 is even considered since I explicitly link against libpng15.so.15.4.0</p>