问题
I am getting the following issue:
/Users/luke/Desktop/trainHOG/trainhog ; exit;
dyld: Library not loaded: lib/libopencv_core.3.0.dylib
Referenced from: /Users/luke/Desktop/trainHOG/trainhog
Reason: image not found
Trace/BPT trap: 5
logout
I am using a Mac running OSX v10.9.5 with openCV 3.0 alpha.
The library in question is definitely in the folder. I have tried deleting it and pasting it back into the folder, I have completely deleted and reinstalled openCV and macports, and I have tried the export DYLD_LIBRARY_PATH = "path to dynamic libs here.."
, but nothing has worked. I have even rebooted my computer on several occasions!
Does anyone have any further suggestions? I am out of ideas
回答1:
OpenCV 3.3 OSX 10.13 fist have a test, you can use clang++ -o a -I ./include -L ./lib -lopencv_core.your.version then you can generate executable file a ,run it ,if have the error massage. you will find the error reason cannot find the lib when you are link.
if you want to solve error on terminal you can use export DYLD_LIBRARY_PATH=your/lib:$DYLD_LIBRARY_PATH if you want to solve error on Xcode in build page , go to "Runpath Search Paths" add you lib path
回答2:
If you use
export DYLD_LIBRARY_PATH = "path to dynamic libs here.."
is it applied to the environment of your program? You can check the environment variables of a running process with
ps -p <pid> -wwwE
Does this help?
回答3:
Seems to be a bug in some versions of OpenCV's CMake configuration files which incorrectly record relative paths in the installed dylibs, reasonably easy to fix.
This answer on answers.opencv.org addresses the issue. In OpenCVModule.cmake
and every instance of CMakeLists.txt
replace INSTALL_NAME_DIR lib
with INSTALL_NAME_DIR ${CMAKE_INSTALL_PREFIX}/lib
.
来源:https://stackoverflow.com/questions/26978806/dyld-library-not-loaded-lib-libopencv-core-3-0-dylib-reason-image-not-found