1

I have an application that requires OpenCV 2.4.11 to link, so in my make file I ensure I use the following linker flag pattern:

-l:libopencv_core.so.2.4.11

How robust is this assumption?

My specific problem is with my own machine, Ubuntu 14.04, which has v2.4.7 as default, so if I just use -lopencv_core I get the wrong version pulled in. I use cv::fisheye which is a 2.4.11 or later feature, and CMake's find_package(OpenCV) doesn't have a version specification feature.

2

That makes it rely upon a specific package configuration (rather fragile). It wouldn't run against an earlier or later version of the library.

If your application requires some specific feature (which cannot be immediately checked by success/failure in linking), the usual approach is to write some initialization code which checks for the release-version of the library (many, not all libraries have a version-function or global variable).

For instance, OpenCV (according to How to determine OpenCV version) has such a function:

printf("OpenCV: %s", cv::getBuildInformation().c_str());

Further reading: OpenCV 2.4.10 documentation for getBuildInformation:

Returned value is raw cmake output including version control system revision, compiler version, compiler flags, enabled modules and third party libraries, etc. Output format depends on target architecture.

  • My specific problem is with my own machine, Ubuntu 14.04, which has v2.4.7 as default, so if I just use -lopencv_core I get the wrong version pulled in. I use cv::fisheye which is a 2.4.11 or later feature, and CMake's find_package(OpenCV) doesn't have a version specification feaure. – Ken Y-N Jul 29 '16 at 0:13
  • Regarding CMake, it's scriptable and you could revise its macros to do many things (outside the scope of this question). A runtime check on the resulting executable is more straightforward. – Thomas Dickey Jul 29 '16 at 0:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.