2

So I am trying to create a simple OpenCV project. I downloaded OpenCV from here:

http://opencv.org/downloads.html

I have unarchived the downloaded file with:

tar xzvf opencv2.framework

I downloaded and installed latest XCode 4.6 for Mountain Lion + command line tools. I then created a new app called GeekOut in XCode and linked OpenCV framework to it:

enter image description here

This is what I get when I click run:

enter image description here

Any ideas? I have been struggling with this for several hours. I have created like 6 new projects and tried linking the library in different ways (drag and drop, by clicking on + in Link Binary With Libraries under Build Phases tab etc).

Richard Knop
  • 81,041
  • 149
  • 392
  • 552
  • I would love to see what happens when you build your program directly from the command line: **g++ test.cpp -o test \`pkg-config --cflags --libs opencv\`** – karlphillip Apr 06 '13 at 15:12
  • @karlphillip I don't have any cpp files, it's objective C. I am following this tutorial: http://docs.opencv.org/doc/tutorials/ios/hello/hello.html#opencvioshelloworld – Richard Knop Apr 06 '13 at 15:46
  • Drag and dropping the framework seems to work for me. Have you tried re-downloading the framework? Switching to device (not simulator) scheme? – zrslv Apr 06 '13 at 16:08
  • @zrxq When I test it on device, I get error as well. It says Undefined symbols for architecture armv7: "_OBJC_CLASS_$_CvVideoCamera", referenced from: objc-class-ref in ViewController.o ld: symbol(s) not found for architecture armv7 clang: error: linker command failed with exit code 1 (use -v to see invocation) – Richard Knop Apr 06 '13 at 16:43
  • Why do you reference CvVideoCamera from ViewController, it's not in the tutorial! I guess your problem is you're linking C++ library against Obj-C (as opposed to Obj-C++), but I'm not sure. – zrslv Apr 06 '13 at 19:14
  • see that:[stackOverflow](http://stackoverflow.com/questions/27772151/apple-mach-o-linker-warning-directory-not-found-for-option/37894243#37894243) it will solve that. – kuperxu Mar 08 '17 at 06:58
  • Does this answer your question? [Xcode linker error: file too small for architecture x86\_64](https://stackoverflow.com/questions/14034048/xcode-linker-error-file-too-small-for-architecture-x86-64) – pkamb Nov 20 '20 at 01:11

4 Answers4

9

Have you tried to clean build (Cmd+K)?

Ondrej Rafaj
  • 4,342
  • 8
  • 42
  • 65
0

I had the same problem. I solved it just by copying the "opencv2" file from .../opencv2.framework/Versions/A/ into .../opencv2.framework/

nicola
  • 1
0

Problem is on your architecture.So change the architecture to armv7

MK_iOS
  • 388
  • 5
  • 13
0

Try a simple "Clean" and "Build" : Cmd + Shift + K

Matthew Usdin
  • 1,264
  • 1
  • 19
  • 20