0

I'm following this: http://sadeepj.blogspot.com.br/2012/03/installing-and-configuring-opencv-to.html

I had a problem, compiling. But I already fixed it, modifying 2 files...

Now I'm trying to run that example.

And I get this error message:

Ld /Users/eduardoreis/Library/Developer/Xcode/DerivedData/DemoOpenCV2-cqudsdzwopsadacnkbwrsxuncofg/Build/Products/Debug/DemoOpenCV2 normal x86_64 cd /Users/eduardoreis/Documents/XCodeDevelopment/DemoOpenCV2 setenv MACOSX_DEPLOYMENT_TARGET 10.8 /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.8.sdk -L/Users/eduardoreis/Library/Developer/Xcode/DerivedData/DemoOpenCV2-cqudsdzwopsadacnkbwrsxuncofg/Build/Products/Debug -F/Users/eduardoreis/Library/Developer/Xcode/DerivedData/DemoOpenCV2-cqudsdzwopsadacnkbwrsxuncofg/Build/Products/Debug -filelist /Users/eduardoreis/Library/Developer/Xcode/DerivedData/DemoOpenCV2-cqudsdzwopsadacnkbwrsxuncofg/Build/Intermediates/DemoOpenCV2.build/Debug/DemoOpenCV2.build/Objects-normal/x86_64/DemoOpenCV2.LinkFileList -mmacosx-version-min=10.8 -stdlib=libc++ -lopencv_core.2.4.6 -lopencv_highgui.2.4.6 -Xlinker -dependency_info -Xlinker /Users/eduardoreis/Library/Developer/Xcode/DerivedData/DemoOpenCV2-cqudsdzwopsadacnkbwrsxuncofg/Build/Intermediates/DemoOpenCV2.build/Debug/DemoOpenCV2.build/Objects-normal/x86_64/DemoOpenCV2_dependency_info.dat -o /Users/eduardoreis/Library/Developer/Xcode/DerivedData/DemoOpenCV2-cqudsdzwopsadacnkbwrsxuncofg/Build/Products/Debug/DemoOpenCV2

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

I follows all steps already. And I can't even build it. Please, help me.

[Before someone says that it is a duplicated post, I know it, here is the original one: C++ linker errors with OpenCV. I'm sorry. But I can't even comment on that one :/ ]

1 Answer 1

1

Wow, Finally solved:

Some considerations:

  • Realize that even it is looking for -l opencv_core.2.4.6, the compiler will get the right file, if it is added correctly with other name, in this case libopencv_core.2.4.dylib
  • I was adding the files with Project>Add files to... and then creating a group and dragging the files into the group. This was messing up the linkings in Project>Link Binary with Libraries. So I had to do it again by dragging the files in the group into that spot.

After theses things I had the situation where I had the two files (core and highgui) and 4 errors:

Ld /Users/eduardoreis/Library/Developer/Xcode/DerivedData/DemoOpenCV2-cqudsdzwopsadacnkbwrsxuncofg/Build/Products/Debug/DemoOpenCV2 normal x86_64 cd /Users/eduardoreis/Documents/XCodeDevelopment/DemoOpenCV2 setenv MACOSX_DEPLOYMENT_TARGET 10.8 /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.8.sdk -L/Users/eduardoreis/Library/Developer/Xcode/DerivedData/DemoOpenCV2-cqudsdzwopsadacnkbwrsxuncofg/Build/Products/Debug -L/Users/eduardoreis/Downloads/opencv-2.4.6.1/build/lib/Debug -L/usr/local/lib/python2.7/site-packages -L/usr/local/lib/python2.7/site-packages/PyQt4 -L/usr/local/lib/wine -L/usr/local/Cellar/wine/1.4.1/lib -L/usr/local/Cellar/qt/4.8.5/lib -L/usr/local/Cellar/qscintilla2/2.7.1/lib -L/usr/local/Cellar/libicns/0.8.1/lib -L/usr/local/Cellar/jasper/1.900.1/lib -L/usr/local/Cellar/jpeg/8d/lib -L/usr/local/Cellar/little-cms/1.19/lib -L/usr/local/Cellar/libpng/1.5.14/lib -L/usr/local/Cellar/libtiff/4.0.3/lib -F/Users/eduardoreis/Library/Developer/Xcode/DerivedData/DemoOpenCV2-cqudsdzwopsadacnkbwrsxuncofg/Build/Products/Debug -F/usr/local/lib -filelist /Users/eduardoreis/Library/Developer/Xcode/DerivedData/DemoOpenCV2-cqudsdzwopsadacnkbwrsxuncofg/Build/Intermediates/DemoOpenCV2.build/Debug/DemoOpenCV2.build/Objects-normal/x86_64/DemoOpenCV2.LinkFileList -mmacosx-version-min=10.8 -stdlib=libc++ -lopencv_core.2.4 -lopencv_highgui.2.4 -Xlinker -dependency_info -Xlinker /Users/eduardoreis/Library/Developer/Xcode/DerivedData/DemoOpenCV2-cqudsdzwopsadacnkbwrsxuncofg/Build/Intermediates/DemoOpenCV2.build/Debug/DemoOpenCV2.build/Objects-normal/x86_64/DemoOpenCV2_dependency_info.dat -o /Users/eduardoreis/Library/Developer/Xcode/DerivedData/DemoOpenCV2-cqudsdzwopsadacnkbwrsxuncofg/Build/Products/Debug/DemoOpenCV2

Undefined symbols for architecture x86_64:
"cv::namedWindow(std::__1::basic_string, std::__1::allocator > const&, int)", referenced from: _main in main.o "cv::imread(std::__1::basic_string, std::__1::allocator > const&, int)", referenced from: _main in main.o "cv::imshow(std::__1::basic_string, std::__1::allocator > const&, cv::_InputArray const&)", referenced from: _main in main.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

Then (thanks God and some days of googling) I got this:

Select your project, go to the Build Settings tab, filter by c++ standard library, and set this parameter to libstdc++ (GNU C++ standard library).

from: Undefined symbols for architecture x86_64 error when linking OpenCV in Xcode

And finally it was sunny again in my code environment...

Sign up to request clarification or add additional context in comments.

3 Comments

For some reason I getting again this problem. Even changing to c++ standard library. :/
can you explain the "by dragging the files in the group into that spot."
I had mysterious (at least, to me) linking errors and that last instruction saved me: "Select your project, go to the Build Settings tab, filter by c++ standard library, and set this parameter to libstdc++ (GNU C++ standard library)." Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.