Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[develop2] linking with opencv: at runtime does not find features2d and calib3d, others working #15275

Closed
metalMajor opened this issue Dec 14, 2023 · 4 comments
Assignees

Comments

@metalMajor
Copy link

metalMajor commented Dec 14, 2023

Hello,

I use the conan_provider.cmake and that works all very well, so I have a library to which I link opencv this:

find_package(OpenCV REQUIRED COMPONENTS core imgproc features2d video calib3d)
target_link_libraries(myLib 
  PUBLIC
     opencv_core
    opencv_imgproc
    opencv_features2d
    opencv_video
    opencv_calib3d
)

And then I use that library in a (unittest) executable that I am creating:

target_link_libraries(myTest PUBLIC myLib)

Everything compiles and links, but when I start my tests using for example "ctest" in the build dir, then it only finds the "core", "imgproc" and "video" libraries, but not "features2d" and "calib3d". However, they exist in the same directory on my system under $HOME/.conan2/......lib. So they are there for sure. When not using the "features2d" and "calib3d" libraries, then it all works... so...

The only thing I see is that the not-working libraries have a number in their names, and the other ones not... or am I paranoia haha. It's suspicious!

Just adding: it works on macos, but not on a linux box.

@memsharded memsharded self-assigned this Dec 14, 2023
@memsharded
Copy link
Member

Hi @metalMajor

I think this wouldn't be related to the cmake-conan integration at all, but to Conan and the recipes involved, I think this could be replicated with normal conan install + cmake ... commands. It would be great to do so to discard the effect of cmake-conan.

Then, this seems like an effect of RPATHs, and that is kind of expected, when using packages built in another machine, only the directly linked libraries will be in the executable RPATH, but the transitive ones might not be. This is typically addressed by activating the conanrun environment (source conanrun.sh in Linux) before executing things that depend on shared libs of the host context (like tests in this case). Can you please try that?

@metalMajor
Copy link
Author

Hi, thanks for the quick reply! It works when I indeed first source the "conan/conanrun.sh" in the build dir!

(sorry for posting here, it's sometimes difficult to know where it's most relevant 🙈 )

@memsharded
Copy link
Member

No prob, we can transfer tickets as necessary, I will move this one to "conan" repo because it is then a question about Conan itself.

@memsharded memsharded transferred this issue from conan-io/cmake-conan Dec 14, 2023
@memsharded
Copy link
Member

Hi, thanks for the quick reply! It works when I indeed first source the "conan/conanrun.sh" in the build dir!

That is great, so I think we can consider the issue resolved?
In any case, I think you might be interested in #15192, it generates the environment variables directly into a generated CMakePresets. It requires inversion of control, that means, not using cmake-conan, but following the "standard" flow of conan install + cmake --preset ..., but it might be worth the convenience

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants