Remove useless transitive dependencies when using shared libraries (Patch #1924)


Added by Del Thanil almost 13 years ago. Updated almost 13 years ago.


Status:Cancelled Start date:2012-05-11
Priority:Normal Due date:
Assignee:Andrey Kamaev % Done:

0%

Category:build/install
Target version:2.4.1 Estimated time:0.50 hour
Affected version: Operating System:
Difficulty: HW Platform:
Pull request:

Description

The calib3d, gnu, nonfree and stitching modules do not depend on the highgui module. However, since they all depend on other modules that depend on highgui, these modules are linked to highgui.
These links are useless if using shared libraries.
To remove these useless links, the following patch can be added to the root CMakeLists.txt file, right before the summary for example.

foreach(OPENCV_MODULE_BUILT in ${OPENCV_MODULES_BUILD})
  if(TARGET ${OPENCV_MODULE_BUILT})
    set_target_properties(${OPENCV_MODULE_BUILT} PROPERTIES LINK_INTERFACE_LIBRARIES "")
  endif(TARGET ${OPENCV_MODULE_BUILT})
endforeach(OPENCV_MODULE_BUILT in ${OPENCV_MODULES_BUILD})

Associated revisions

Revision 098d4e61
Added by Andrey Pavlenko over 11 years ago

Merge pull request #1924 from ilya-lavrenov:svm

History

Updated by Andrey Kamaev almost 13 years ago

Can you explain why the dependencies are useless? What the problem those dependencies make for you?
Anyway if you are using opencv_stitching (for example) you still need to have opencv_highgui binary to start your executable.

  • Target version deleted (2.4.1)
  • Assignee changed from Alexander Shishkov to Andrey Kamaev

Updated by Del Thanil almost 13 years ago

Well it's not a major problem. I came across it while modifying the generated shared libraries. It's just that since those dependencies can be avoided, I thought it best to remove them. If for example A depends on B and B depends on C but B can actually start with less features if it detects at runtime that C isn't there, than adding a dependency from A to C will prevent A from running when it actually could. The patch proposed can avoid that. But yes, seeing how OpenCV works as of today, it does not directly add functionality.

Updated by Andrey Kamaev almost 13 years ago

So I'm cancelling this report because it does not make an improvement for the library. And even without explicit dependencies the dependency implicitly exist and will not allow to run any application without the opencv_highgui module.
Anyway transitive linking is a tricky issue. Here is a good thread highlighting some scenarios where it helps.

Also if you need, you can build OpenCV 2.4 without highgui at all. Just set BUILD_opencv_highgui CMake variable to OFF.

  • Status changed from Open to Cancelled
  • Target version set to 2.4.1

Also available in: Atom PDF