Ask Your Question
0

Linker error only with DNN module

asked 2019-07-29 03:22:43 -0600

Hordon gravatar image

I work on a C++ project with OpenCV 4.1.0_2 on the latest macOS Mojave with Xcode 11 beta. I used a lot of elements from the library without any problem but when I try to use the DNN module I got a linker error. Linker flags should not be the problem since I added it all, and because every other module I used is link fine I guess the header and source directories are should be fine as well. What could be the problem? The error messages:

Ld /Users/hordon/Library/Developer/Xcode/DerivedData/project-fmllzddvpyajkjbwntzsyqvmunjx/Build/Products/Debug/OpenCV normal x86_64 (in target: OpenCV)
    cd /Users/hordon/Desktop/GreenFox/OpenCV
    /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -target x86_64-apple-macos10.14 -isysroot /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -L/Users/hordon/Library/Developer/Xcode/DerivedData/project-fmllzddvpyajkjbwntzsyqvmunjx/Build/Products/Debug -L/usr/local/Cellar/opencv/4.1.0_2/lib -L/usr/local/Cellar/sqlite/3.28.0/lib -L/usr/local/Cellar/tesseract/4.0.0_1/lib -L/usr/local/Cellar/leptonica/1.78.0/lib -F/Users/hordon/Library/Developer/Xcode/DerivedData/project-fmllzddvpyajkjbwntzsyqvmunjx/Build/Products/Debug -filelist /Users/hordon/Library/Developer/Xcode/DerivedData/project-fmllzddvpyajkjbwntzsyqvmunjx/Build/Intermediates.noindex/project.build/Debug/OpenCV.build/Objects-normal/x86_64/OpenCV.LinkFileList -Xlinker -object_path_lto -Xlinker /Users/hordon/Library/Developer/Xcode/DerivedData/project-fmllzddvpyajkjbwntzsyqvmunjx/Build/Intermediates.noindex/project.build/Debug/OpenCV.build/Objects-normal/x86_64/OpenCV_lto.o -Xlinker -export_dynamic -Xlinker -no_deduplicate -stdlib=libc++ -I/usr/local/Cellar/opencv/4.1.0_2/include/opencv4/opencv -I/usr/local/Cellar/opencv/4.1.0_2/include/opencv4 -L/usr/local/Cellar/opencv/4.1.0_2/lib -lopencv_gapi -lopencv_stitching -lopencv_aruco -lopencv_bgsegm -lopencv_bioinspired -lopencv_ccalib -lopencv_dnn_objdetect -lopencv_dpm -lopencv_face -lopencv_freetype -lopencv_fuzzy -lopencv_hfs -lopencv_img_hash -lopencv_line_descriptor -lopencv_quality -lopencv_reg -lopencv_rgbd -lopencv_saliency -lopencv_sfm -lopencv_stereo -lopencv_structured_light -lopencv_phase_unwrapping -lopencv_superres -lopencv_optflow -lopencv_surface_matching -lopencv_tracking -lopencv_datasets -lopencv_text -lopencv_dnn -lopencv_plot -lopencv_videostab -lopencv_video -lopencv_xfeatures2d -lopencv_shape -lopencv_ml -lopencv_ximgproc -lopencv_xobjdetect -lopencv_objdetect -lopencv_calib3d -lopencv_features2d -lopencv_highgui -lopencv_videoio -lopencv_imgcodecs -lopencv_flann -lopencv_xphoto -lopencv_photo -lopencv_imgproc -lopencv_core -ltesseract -lsqlite3 -Xlinker -dependency_info -Xlinker /Users/hordon/Library/Developer/Xcode/DerivedData/project-fmllzddvpyajkjbwntzsyqvmunjx/Build/Intermediates.noindex/project.build/Debug/OpenCV.build/Objects-normal/x86_64/OpenCV_dependency_info.dat -o /Users/hordon/Library/Developer/Xcode/DerivedData/project-fmllzddvpyajkjbwntzsyqvmunjx/Build/Products/Debug/OpenCV

and

Undefined symbols for architecture x86_64:
  "cv::dnn::dnn4_v20180917::blobFromImage(cv::_InputArray const&, cv::_OutputArray const&, double, cv::Size_<int> const&, cv::Scalar_<double> const&, bool, bool, int)", referenced from:
      detectText(cv::Mat, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >) in detectText.o
  "cv::dnn::dnn4_v20180917::Net::forward(cv::_OutputArray const&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&)", referenced from:
      detectText(cv::Mat, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >) in detectText.o
  "cv::dnn::dnn4_v20180917::Net::setInput(cv::_InputArray const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, double, cv::Scalar_<double> const&)", referenced from:
      detectText(cv::Mat, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >) in detectText.o
  "cv::dnn ...
(more)
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2019-08-13 16:29:43 -0600

Hordon gravatar image

Meanwhile, I found a solution, so I leave it here in case anybody struggles with the same issue. If you installed OpenCV with Homebrew's brew install opencv command the DNN module won't be compiled. You have to rebuild it from source which you can achieve with the brew reinstall opencv --build-from-source command. Since at this point my search paths were added correctly I just had to build my project again, which was done without any error.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2019-07-29 03:22:43 -0600

Seen: 835 times

Last updated: Aug 13 '19