title: Linking fails with CMake, DSO-Link-Change
body: <p>My software that compiled fine on linux a few months ago stopped compiling on my new ubuntu:</p>
  
  <pre><code>Linking CXX executable myApp
  /usr/bin/ld: ../libMyLib/libMyLib.a(MyFile.cpp.o): undefined reference to symbol '_ZN2cv6resizeERKNS_11_InputArrayERKNS_12_OutputArrayENS_5Size_IiEEddi'
  /usr/bin/ld: note: '_ZN2cv6resizeERKNS_11_InputArrayERKNS_12_OutputArrayENS_5Size_IiEEddi' is defined in DSO /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../lib/libopencv_imgproc.so so try adding it to the linker command line
  /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../lib/libopencv_imgproc.so: could not read symbols: Invalid operation
  collect2: error: ld returned 1 exit status
  make[2]: *** [myApp/myApp] Error 1
  make[1]: *** [myApp/CMakeFiles/myApp.dir/all] Error 2
  make: *** [all] Error 2
  </code></pre>
  
  <p>I guess it's related to <a href="https://fedoraproject.org/wiki/UnderstandingDSOLinkChange" rel="nofollow">https://fedoraproject.org/wiki/UnderstandingDSOLinkChange</a>.</p>
  
  <p>My project (all cmake) contains several libraries and an application, both the libraries and the application depend on opencv and/or boost (each on some different ones). My own libraries are built as .a files, ocv/boost are pulled in as shared libraries, and the linking of the application then fails with above error.</p>
  
  <p>I also tried to build my own libraries as SHARED but that resulted in even more errors. The CMakeLists of my libraries look like</p>
  
  <pre><code>FIND_PACKAGE(Boost REQUIRED)
  FIND_PACKAGE(OpenCV REQUIRED core)
  ...stuff...
  include_directories( ${OpenCV_INCLUDE_DIRS} )
  include_directories( ${Boost_INCLUDE_DIRS} )
  add_library( ${SUBPROJECT_NAME} ${SOURCE} ${HEADERS} )
  </code></pre>
  
  <p>The application CMakeLists looks like</p>
  
  <pre><code>FIND_PACKAGE( OpenCV REQUIRED core imgproc highgui)
  include_directories( ${OpenCV_INCLUDE_DIRS} )
  TARGET_LINK_LIBRARIES( ${SUBPROJECT_NAME} ${OpenCV_LIBS} MyLib )
  </code></pre>
  
  <p>That was all correct and I always thought that's the way to do it but now with this DSO stuff I just cannot get it to work anymore.</p>
  
  <p>If relevant, I tried with CMake 2.8.7 and 2.8.10, and g++ 4.7.2 and 4.8, all produce the same errors.</p>