Ask Your Question
1

Problem with Stitching on iOS 6

asked 2012-10-24 18:14:58 -0600

avemprala gravatar image

updated 2012-11-01 14:22:43 -0600

Hello folks!

I'm trying to get a small app going that stitches images together using OpenCV on iOS. I've started by including the pre-built OpenCV 2 framework in my iOS project and setting up appropriate references. However, when I try and initiate a stitch operation, I get these linker errors:

Undefined symbols for architecture i386:
  "cv::_InputArray::~_InputArray()", referenced from:
      -[ViewController viewDidLoad] in ViewController.o
  "cv::_OutputArray::~_OutputArray()", referenced from:
      -[ViewController viewDidLoad] in ViewController.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Here's what my view controller code looks like:

- (void)viewDidLoad
{
    [super viewDidLoad];

    UIImage* leftImage = [UIImage imageNamed:@"ridge-left.jpg"];
    UIImage* rightImage = [UIImage imageNamed:@"ridge-right.jpg"];

    UIImageView* testImageView = [[UIImageView alloc] initWithImage:leftImage];
    [self.view addSubview:testImageView];

    vector<Mat> images;
    Mat leftMat = [leftImage toCVMat];
    Mat rightMat = [rightImage toCVMat];
    Mat panoramic;

    images.push_back(leftMat); images.push_back(rightMat);

    Stitcher stitcher = Stitcher::createDefault(false);
//    stitcher.setWarper(new CylindricalWarper());
    Stitcher::Status st = stitcher.stitch(images, panoramic);

}

I'm pretty new to OpenCV so I'm not sure if I'm using the APIs incorrectly or if there's something else at play. I should note that commenting out the call to stitcher.stitch() removes the linker error, so it has something to do with that method. I noticed that the destructors its complaining about have these macro settings (in core.hpp). Not sure what those mean, but could they be a factor?

#ifdef OPENCV_CAN_BREAK_BINARY_COMPATIBILITY
    virtual ~_InputArray();
#endif

#ifdef OPENCV_CAN_BREAK_BINARY_COMPATIBILITY
    virtual ~_OutputArray();
#endif

Appreciate any and all the help!

Thanks, Ani

UPDATE: I'm still having trouble with this. I've tried changing the target to iOS device, but I still get the same error for armv7 architecture. Any ideas?

Ld /Users/aniv/Library/Developer/Xcode/DerivedData/HelloOpenCV-fgbktrcekkodywhgrueujeajztog/Build/Intermediates/HelloOpenCV.build/Debug-iphoneos/HelloOpenCV.build/Objects-normal/armv7/HelloOpenCV normal armv7
    cd /Users/aniv/Dev/HelloOpenCV
    setenv IPHONEOS_DEPLOYMENT_TARGET 6.0
    setenv PATH "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -arch armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk -L/Users/aniv/Library/Developer/Xcode/DerivedData/HelloOpenCV-fgbktrcekkodywhgrueujeajztog/Build/Products/Debug-iphoneos -F/Users/aniv/Library/Developer/Xcode/DerivedData/HelloOpenCV-fgbktrcekkodywhgrueujeajztog/Build/Products/Debug-iphoneos -F/Users/aniv/Dev/HelloOpenCV/../opencv/ios -F/Users/aniv/Dev/HelloOpenCV/HelloOpenCV -filelist /Users/aniv/Library/Developer/Xcode/DerivedData/HelloOpenCV-fgbktrcekkodywhgrueujeajztog/Build/Intermediates/HelloOpenCV.build/Debug-iphoneos/HelloOpenCV.build/Objects-normal/armv7/HelloOpenCV.LinkFileList -dead_strip -fobjc-arc -fobjc-link-runtime -stdlib=libstdc++ -miphoneos-version-min=6.0 -framework opencv2 -framework AVFoundation -framework ImageIO -lz -framework CoreMedia -framework CoreVideo -framework UIKit -framework Foundation -framework CoreGraphics -o /Users/aniv/Library/Developer/Xcode/DerivedData/HelloOpenCV-fgbktrcekkodywhgrueujeajztog/Build/Intermediates/HelloOpenCV.build/Debug-iphoneos/HelloOpenCV.build/Objects-normal/armv7/HelloOpenCV

Undefined symbols for architecture armv7:
  "cv::_OutputArray::~_OutputArray()", referenced from:
      -[ViewController viewDidLoad] in ViewController.o
  "cv::_InputArray::~_InputArray()", referenced from:
      -[ViewController viewDidLoad] in ViewController.o
ld: symbol(s) not ...
(more)
edit retag flag offensive close merge delete

Comments

Are you compiling for emulator? If not, something is broken with your project settings, because it tries to make a binary for x86: ld: symbol(s) not found for architecture i386

sammy gravatar imagesammy ( 2012-10-25 12:03:10 -0600 )edit

Yes, I'm trying to get it to work for the iOS simulator.

avemprala gravatar imageavemprala ( 2012-10-26 09:12:19 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2012-11-01 21:51:01 -0600

avemprala gravatar image

More trial and error has led me to a solution. It seems to be a problem with OpenCV 2.4.2, however, it seems resolved in OpenCV 2.4.3-rc.

My steps, in a nutshell,

  1. The problem does seem to be related to the binary incompatibility flags for the virtual destructor methods.
  2. I had to download 2.4.3 release candidate from Github and compile per the Readme instructions in the ios/ folder. (If you're on Mac OSX, make sure you're running the right version of CMake)
  3. Modify the build_framework.py script to consume the output of step 2 to build opencv2.framework (the original script was expecting the library binaries and headers to be in different paths). Specifically, I just used put_framework_together(src,dest) and hardcoded the paths to the binaries and headers.
  4. Followed the library linking steps in the iOS instructions to add the framework to my Xcode project.
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2012-10-24 18:14:58 -0600

Seen: 1,561 times

Last updated: Nov 01 '12