Ask Your Question

ios 6 and xcode 4.5 linker problems

asked 2012-10-04 14:51:07 -0500

Guillaume gravatar image

updated 2012-10-04 23:26:35 -0500


I have been able to compile opencv correctly for ios 6 (i think), but when I try to add it to my project and compile my project, I got Apple Mach-O Linker Error such as:

Ld /Users/guillaume/Library/Developer/Xcode/DerivedData/panios-ebjroeuwobrkpjcdgkitygqxtrig/Build/Products/Debug-iphoneos/ normal armv7
    cd /Users/guillaume/Clients/Trax/panios/app
    setenv PATH "/Applications/"
    /Applications/ -arch armv7 -isysroot /Applications/ -L/Users/guillaume/Library/Developer/Xcode/DerivedData/panios-ebjroeuwobrkpjcdgkitygqxtrig/Build/Products/Debug-iphoneos -F/Users/guillaume/Library/Developer/Xcode/DerivedData/panios-ebjroeuwobrkpjcdgkitygqxtrig/Build/Products/Debug-iphoneos -F/Users/guillaume/Clients/Trax/panios/app -filelist /Users/guillaume/Library/Developer/Xcode/DerivedData/panios-ebjroeuwobrkpjcdgkitygqxtrig/Build/Intermediates/ -dead_strip -weak_framework CoreFoundation -weak_framework UIKit -weak_framework AVFoundation -weak_framework CoreMedia -weak-lSystem -all_load -Obj-C -fobjc-link-runtime -miphoneos-version-min=4.3 -framework opencv2 -framework AssetsLibrary -framework CoreVideo /Users/guillaume/Library/Developer/Xcode/DerivedData/panios-ebjroeuwobrkpjcdgkitygqxtrig/Build/Products/Debug-iphoneos/libCordova.a -framework Foundation -weak_framework UIKit -framework CoreGraphics -framework AddressBook -framework AddressBookUI -framework AudioToolbox -weak_framework AVFoundation -framework CFNetwork -framework CoreLocation -framework MediaPlayer -framework QuartzCore -framework SystemConfiguration -framework MobileCoreServices -weak_framework CoreMedia -o /Users/guillaume/Library/Developer/Xcode/DerivedData/panios-ebjroeuwobrkpjcdgkitygqxtrig/Build/Products/Debug-iphoneos/

Undefined symbols for architecture armv7:
  "vtable for __cxxabiv1::__vmi_class_type_info", referenced from:
      typeinfo for cv::Feature2D in opencv2(brisk.o)
      typeinfo for cv::DescriptorExtractor in opencv2(descriptors.o)
      typeinfo for cv::FeatureDetector in opencv2(detectors.o)
  NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
  "std::string::assign(char const*, unsigned long)", referenced from:
      cv::BmpDecoder::BmpDecoder() in opencv2(grfmt_bmp.o)
      cv::BmpEncoder::BmpEncoder() in opencv2(grfmt_bmp.o)
      cv::BmpEncoder::newEncoder() const in opencv2(grfmt_bmp.o)
      cv::PxMEncoder::PxMEncoder() in opencv2(grfmt_pxm.o)
      cv::PxMEncoder::newEncoder() const in opencv2(grfmt_pxm.o)
      cv::SunRasterDecoder::SunRasterDecoder() in opencv2(grfmt_sunras.o)
      cv::SunRasterEncoder::SunRasterEncoder() in opencv2(grfmt_sunras.o)
  "std::cout", referenced from:
      cv::LDA::lda(cv::_InputArray const&, cv::_InputArray const&) in opencv2(lda.o)
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Showing first 200 notices only

I have only added the generated opencv2.framework to my project and added:

#ifdef __cplusplus
    #import <opencv2/opencv.hpp>

At the beginning of my *-Prefix.pch file

Any idea what could be the problem?

Thank you!

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted

answered 2012-12-02 21:51:32 -0500

John Brewer gravatar image

It looks like your project is not linking against the C++ runtime library. To link against the runtime library:

  • Go to the "Build Phases" tab of the project .
  • Choose the "Link Binary With Libraries" section.
  • Click the "+" button at the bottom of the section.
  • From the list that appears, choose either "libc++.dylib" for OpenCV 2.4.3, or "libstdc++.dylib" for OpenCV 2.4.2 and before.

Rebuild, and everything should work.

edit flag offensive delete link more

answered 2012-10-04 23:10:19 -0500

Foxfire gravatar image

How do you know if the compiled correctly? I've had some issues compiling and after several attempts only the instructions from this link worked

edit flag offensive delete link more


@Foxfire I have followed these instructions and it returned a message that the build had succeeded and there was an opencv2.framework generated. So I think the compilation worked just fine. Isn't it?

Guillaume gravatar imageGuillaume ( 2012-10-04 23:23:08 -0500 )edit

@Guillaume Yes. Sounds like everything worked as it should.

Foxfire gravatar imageFoxfire ( 2012-10-13 19:15:35 -0500 )edit

Question Tools

1 follower


Asked: 2012-10-04 14:51:07 -0500

Seen: 6,313 times

Last updated: Dec 02 '12