title: Cmake: linking shared library
body: <p>I've done this before a couple of times, but somehow I'm stuck this time. I have an executable "myapp" and a own shared library "mylib". In my cmakelists I have the following:</p>
  
  <pre><code>ADD_LIBRARY(mylib SHARED ${SOURCES_LIB})
  INSTALL(TARGETS mylib DESTINATION .)
  ADD_EXECUTABLE(myapp ${SOURCES_APP})
  TARGET_LINK_LIBRARIES(myapp ${QT_LIBRARIES} mylib)
  INSTALL(TARGETS myapp DESTINATION .)
  </code></pre>
  
  <p>Everything compiles and links correctly, but when I start myapp, I get the following error:</p>
  
  <pre><code>error while loading shared libraries: libmylib.so: cannot open shared object file: No such file or directory
  </code></pre>
  
  <p>The lib and the executable are present in the install directory. When I make my library static by changing the first line of the above cmakelists to:</p>
  
  <pre><code>ADD_LIBRARY(mylib STATIC ${SOURCES_LIB})
  </code></pre>
  
  <p>then everything works 100%.</p>
  
  <p>Does anyone know what I'm doing wrong?</p>