我使用Homebrew在OS 10.13.1上安装了OpenCV 3.3.1,并且我遇到了无法诊断的链接器问题。有没有人知道可能会发生什么?
命令行:
g++ backsub.cpp `pkg-config --libs --cflags opencv` -o backsub
返回以下错误消息:
ld: library not found for -llibopencv_stitching.3.3.1.dylib
clang: error: linker command failed with exit code 1 (use -v to see invocation)
使用-v
选项为链接器部分提供(硬包装以便于阅读):
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.
xctoolchain/usr/bin/ld" -demangle -lto_library
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.
xctoolchain/usr/lib/libLTO.dylib -no_deduplicate -dynamic -arch x86_64
-macosx_version_min 10.13.0 -o backsub
-L/usr/local/Cellar/opencv/3.3.1_1/lib
/var/folders/zn/p7grv7lj49lfdrvrtn7mp1kh0000gn/T/backsub-2eda30.o
-llibopencv_stitching.3.3.1.dylib -llibopencv_superres.3.3.1.dylib
-llibopencv_videostab.3.3.1.dylib -llibopencv_photo.3.3.1.dylib
-llibopencv_aruco.3.3.1.dylib -llibopencv_bgsegm.3.3.1.dylib
-llibopencv_bioinspired.3.3.1.dylib -llibopencv_ccalib.3.3.1.dylib
-llibopencv_dpm.3.3.1.dylib -llibopencv_face.3.3.1.dylib
-llibopencv_fuzzy.3.3.1.dylib -llibopencv_img_hash.3.3.1.dylib
-llibopencv_line_descriptor.3.3.1.dylib -llibopencv_optflow.3.3.1.dylib
-llibopencv_reg.3.3.1.dylib -llibopencv_rgbd.3.3.1.dylib
-llibopencv_saliency.3.3.1.dylib -llibopencv_stereo.3.3.1.dylib
-llibopencv_structured_light.3.3.1.dylib
-llibopencv_phase_unwrapping.3.3.1.dylib
-llibopencv_surface_matching.3.3.1.dylib
-llibopencv_tracking.3.3.1.dylib -llibopencv_datasets.3.3.1.dylib
-llibopencv_text.3.3.1.dylib -llibopencv_dnn.3.3.1.dylib
-llibopencv_plot.3.3.1.dylib -llibopencv_xfeatures2d.3.3.1.dylib
-llibopencv_shape.3.3.1.dylib -llibopencv_video.3.3.1.dylib
-llibopencv_ml.3.3.1.dylib -llibopencv_ximgproc.3.3.1.dylib
-llibopencv_calib3d.3.3.1.dylib -llibopencv_features2d.3.3.1.dylib
-llibopencv_highgui.3.3.1.dylib -llibopencv_videoio.3.3.1.dylib
-llibopencv_flann.3.3.1.dylib -llibopencv_xobjdetect.3.3.1.dylib
-llibopencv_imgcodecs.3.3.1.dylib -llibopencv_objdetect.3.3.1.dylib
-llibopencv_xphoto.3.3.1.dylib -llibopencv_imgproc.3.3.1.dylib
-llibopencv_core.3.3.1.dylib -lc++ -lSystem
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.
xctoolchain/usr/lib/clang/9.0.0/lib/darwin/libclang_rt.osx.a
ld: library not found for -llibopencv_stitching.3.3.1.dylib
clang: error: linker command failed with exit code 1 (use -v to see invocation)
pkg-config似乎正在做正确的事情。所有dylib都在/usr/local/Cellar/opencv/3.3.1_1/lib
中,并且具有在命令行中指定的确切文件名。由于某些原因,链接器没有看到它们。谢谢你的帮助!