OBX
OBX

Reputation: 6114

Apple Mach-O Linker (ld) Error Group when OpenCV is added to the library; possible fix?

Apple Mach-O Linker (ld) Error Group , found many existing question with same tag, however none did fix my issue.

I am trying to include OpenCV with my project in order to track hand position. And so far everything works fine, however when I build the project. It gives the error : Apple Mach-O Linker (ld) Error Group .

From the log here is what I obtained :

Ld /Users/shaheenakader/Library/Developer/Xcode/DerivedData/handSeg-fiojpqxgqvrsbxadwvnbdsljpycy/Build/Products/Debug/handSeg normal x86_64 cd /Users/shaheenakader/Documents/tracking export MACOSX_DEPLOYMENT_TARGET=10.9 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -L/Users/shaheenakader/Library/Developer/Xcode/DerivedData/handSeg-fiojpqxgqvrsbxadwvnbdsljpycy/Build/Products/Debug -L/usr/local/lib -F/Users/shaheenakader/Library/Developer/Xcode/DerivedData/handSeg-fiojpqxgqvrsbxadwvnbdsljpycy/Build/Products/Debug -filelist /Users/shaheenakader/Library/Developer/Xcode/DerivedData/handSeg-fiojpqxgqvrsbxadwvnbdsljpycy/Build/Intermediates/handSeg.build/Debug/handSeg.build/Objects-normal/x86_64/handSeg.LinkFileList -mmacosx-version-min=10.9 -Xlinker -object_path_lto -Xlinker /Users/shaheenakader/Library/Developer/Xcode/DerivedData/handSeg-fiojpqxgqvrsbxadwvnbdsljpycy/Build/Intermediates/handSeg.build/Debug/handSeg.build/Objects-normal/x86_64/handSeg_lto.o -Xlinker -export_dynamic -Xlinker -no_deduplicate -stdlib=libc++ -lopencv_calib3d -lopencv_core -lopencv_features2d -lopencv_flann -lopencv_highgui -lopencv_imgcodecs -lopencv_imgproc -lopencv_ml -lopencv_objdetect -lopencv_photo -lopencv_shape -lopencv_stitching -lopencv_superres -lopencv_ts -lopencv_video -lopencv_videoio -lopencv_videostab -lopencv_core.2.4.10 -lopencv_objdetect.2.4.10 -lopencv_highgui.2.4.10 -lopencv_imgproc.2.4.10 -Xlinker -dependency_info -Xlinker /Users/shaheenakader/Library/Developer/Xcode/DerivedData/handSeg-fiojpqxgqvrsbxadwvnbdsljpycy/Build/Intermediates/handSeg.build/Debug/handSeg.build/Objects-normal/x86_64/handSeg_dependency_info.dat -o /Users/shaheenakader/Library/Developer/Xcode/DerivedData/handSeg-fiojpqxgqvrsbxadwvnbdsljpycy/Build/Products/Debug/handSeg

Also,

ld: library not found for -lopencv_imgcodecs clang: error: linker command failed with exit code 1 (use -v to see invocation)

Previously

I manually built the OpenCV library using Cmake .

And inside my Xcode project, I set header search path to : /usr/local/include

and library search path to : /usr/local/lib .

Also, set other linker flags to : -lopencv_calib3d -lopencv_core -lopencv_features2d -lopencv_flann -lopencv_highgui -lopencv_imgcodecs -lopencv_imgproc -lopencv_ml -lopencv_objdetect -lopencv_photo -lopencv_shape -lopencv_stitching -lopencv_superres -lopencv_ts -lopencv_video -lopencv_videoio -lopencv_videostab

What could possibly be causing this issue, and how to resolve this issue? Any help would be much appreciated.

Upvotes: 0

Views: 301

Answers (1)

Quang Hoang
Quang Hoang

Reputation: 150745

It’s not enough just to link libraries in Xcode. You need to add the libraries into the projects. To do so, go to /usr/local/libs and drags them to the project explorer (the left panel of Xcode) and choose to create references on the pop up window. You can uncheck the option copy if needed on that window to avoid unnecessary clones of the libraries.

Upvotes: 0

Related Questions