Open Ju1He1 opened 2 years ago
Hi @Ju1He1! Thanks for reporting this issue.
One option would be to add the virtualrunenv
generator, which generates a file activate_run.sh
which will set LD_LIBRARY_PATH
for you with the correct values. Documentation here: https://docs.conan.io/en/1.46/reference/generators/virtualrunenv.html
Since you are invoking conan
from CMake, you would have to add this to your conan_cmake_configure
call.
You mention that it works without issues on Windows, this is because of this line:
"bin, *.dll -> ./bin/${TYPE}"
This causes Conan to copy the required dll
files and place them next to the executable. While you are also copying the .so
files, it should be noted the runtime linker on Linux does not look for shared libraries next to the executable.
On Linux, for other libraries such like GTest
and jsoncpp
, these will work fine if they dont' have "indirect" dependencies on other libraries. In the case you are reporting, there is a dependency on libopencv_imgcodecs.so
, but an indirect dependency on libopencv_imgproc.so
Please let me know if the virtualrunenv
solution works. I would like to investigate this further - could you run readelf -d
on libopencv_imgcodecs.so
and report the output? Thanks for using Conan and Conan Center :)
Hey @jcar87 thx for your fast answer and your explanations. This make sense now :)
I'd call readelf on those 2 libraries
do you have an idea why this is happening
I also added the virtualrunenv runner to conan_cmake_configure(). Adding this allone did not work. Do ich have the call the generated shell scripts manually as well?
Thx so far for your help :)
hey @jcar87 Unfortunately using the virtualrunenv didn't work for me. I called the generated activate_run.sh via execute_process(), however the declared variables are not properly propagated.
However I found a workaround for me
add_test(NAME ${EXEC_NAME} COMMAND ${EXEC_NAME} WORKING_DIRECTORY "Path/To/Build/Folder")
However this solution only works for the unit tests. A more general solution would be nice :)
Hey guys, I'm using OpenCV from Conan Center. On Windows everything works fine, however on Linux, my application crashes with
error while loading shared libraries: libopencv_imgproc.so.4.5: cannot open shared object file: No such file or directory
running
ldd MyExecutable
gives melibopencv_imageproc is not found. However libopencv_imgcodecs was properly found. I believe there is something missing in the recipe or my project, since parts of opencv are located correctly
My (simplified) setup looks like this
my executable setup is as follows
Am I missing some opencv libs in my target_link_libraries()? Why is libopencv_imgcodecs set but not libopencv_imageproc? When I manually append the build path to the LD_LIBRARY_PATH i can run the executable properly. However I'd like to use a more general solution ;)
Other 3rd parties like Gtest and jsoncpp work fine on windows and linux.
Could you help me out here
Environment Details (include every applicable attribute)