Link errors with opencv2.framework (undefined ref to cv::_InputArray::getUMatVector / getMatVector) with XCode 5 / iOS (Bug #3642)


Added by Ehren Metcalfe almost 11 years ago. Updated over 10 years ago.


Status:Cancelled Start date:2014-04-11
Priority:Normal Due date:
Assignee:- % Done:

0%

Category:-
Target version:-
Affected version:branch 'master' (3.0-dev) Operating System:iOS
Difficulty: HW Platform:ARM
Pull request:

Description

Hello,

When linking opencv2.framework with my application I encounter:

Ld /Users/ehren/Library/Developer/Xcode/DerivedData/Redacted-gubfytvxsjzqfqazulqxsfkvmnar/Build/Products/Debug-iphoneos/Redacted.app/Redacted normal armv7
cd /Users/ehren/Documents/trunk/Redacted
setenv IPHONEOS_DEPLOYMENT_TARGET 5.1
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/iPhoneOS7.0.sdk -L/Users/ehren/Library/Developer/Xcode/DerivedData/Redacted-gubfytvxsjzqfqazulqxsfkvmnar/Build/Products/Debug-iphoneos -F/Users/ehren/Documents/trunk/Redacted/../Libraries/Image -F/Users/ehren/Documents/trunk/Libraries/Image -filelist /Users/ehren/Library/Developer/Xcode/DerivedData/Redacted-gubfytvxsjzqfqazulqxsfkvmnar/Build/Intermediates/Redacted.build/Debug-iphoneos/Universal.build/Objects-normal/armv7/Redacted.LinkFileList -dead_strip -lc++ -fobjc-arc -fobjc-link-runtime -miphoneos-version-min=5.1 -framework opencv2 -framework AudioToolbox -framework MediaPlayer -framework AVFoundation -framework CoreGraphics -framework MobileCoreServices -framework SystemConfiguration -framework CFNetwork -framework ExternalAccessory -framework Security -framework UIKit -framework Foundation -framework CoreVideo -liconv -framework CoreMedia -framework QuartzCore -framework MessageUI -lc++ -framework CoreAudio -framework CoreText -framework Accelerate -Xlinker -dependency_info -Xlinker /Users/ehren/Library/Developer/Xcode/DerivedData/Redacted-gubfytvxsjzqfqazulqxsfkvmnar/Build/Intermediates/Redacted.build/Debug-iphoneos/Universal.build/Objects-normal/armv7/Redacted_dependency_info.dat -o /Users/ehren/Library/Developer/Xcode/DerivedData/Redacted-gubfytvxsjzqfqazulqxsfkvmnar/Build/Products/Debug-iphoneos/Redacted.app/Redacted

Undefined symbols for architecture armv7:
"cv::_InputArray::getMatVector(std::vector<cv::Mat, std::allocator<cv::Mat> >&) const", referenced from:
vtable for cv::_InputOutputArray in Redacted.o
"cv::_InputArray::getUMatVector(std::vector<cv::UMat, std::allocator<cv::UMat> >&) const", referenced from:
vtable for cv::_InputOutputArray in Redacted.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)

This occurs when building the 3.0-ocl-tp2 tag as well as well as current
master (f104d5be8cf54d11b0fcfaf88472f4d6044c891a). I am currently able to link
the 2.4.8 release framework without issue.

(note: this shouldn't be relevant but I did have to apply the workaround from
http://stackoverflow.com/questions/16983696/how-to-build-opencv-2-4-9-for-ios/17025423#17025423
in order to build opencv2.framework)


Associated revisions

Revision 6e565ab4
Added by Vadim Pisarevsky about 10 years ago

Merge pull request #3642 from ilya-lavrenov:linux_x86

History

Updated by Ehren Metcalfe almost 11 years ago

Here is the error with the mangled names:

Undefined symbols for architecture armv7:
"__ZN2cv10erGroupingERKNS_11_InputArrayERSt6vectorIS3_INS_6ERStatESaIS4_EESaIS6_EERKSsfRS3_INS_5Rect_IiEESaISD_EE", referenced from:
_Z15processRedactedRN2cv3MatE in Redacted.o
"
_ZNK2cv11_InputArray12getMatVectorERSt6vectorINS_3MatESaIS2_EE", referenced from:
_ZTVN2cv17_InputOutputArrayE in Redacted.o
__ZTVN2cv17_InputOutputArrayE in Redacted.o
"
_ZNK2cv11_InputArray13getUMatVectorERSt6vectorINS_4UMatESaIS2_EE", referenced from:
__ZTVN2cv17_InputOutputArrayE in Redacted.o
__ZTVN2cv17_InputOutputArrayE in Redacted.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)

grepping the opencv2 static lib I can confirm that __ZN2cv10erGroupingERKNS_11_InputArrayERSt6vectorIS3_INS_6ERStatESaIS4_EESaIS6_EERKSsfRS3_INS_5Rect_IiEESaISD_EE is nowhere to be found.

In addition, I modified the cmake files to export every symbol by removing -fvisibility-inlines-hidden and changing -fvisibility=hidden to -fvisibility=default. This did not work unfortunately.

Updated by Alessandro Trebbi almost 11 years ago

I'll give a look in these days, but i can't assign the bug to myself, maybe because it's open in master branch.
send me an example xcode project ( i'm using latest xcode, 5.1 ), and i'll try and see what is the problem

Updated by Ehren Metcalfe almost 11 years ago

Thanks Alessandro.

I will put together an XCode project (note: I'm still on 5.0.2 but shouldn't be an issue).

One other data point however. This seems to come down to non-trivial use of std:vector !

for example this links fine:

void foo(Mat image) {
vector<vector<Point> > contours;
cout << contours.size();
Canny(image, image, 10, 20, 3);
//findContours(image, contours, RETR_LIST, CHAIN_APPROX_SIMPLE);
}

If you uncomment the call to findContours above you get:

Undefined symbols for architecture armv7:
"cv::_InputArray::getMatVector(std::vector<cv::Mat, std::allocator<cv::Mat> >&) const", referenced from:
vtable for cv::_InputOutputArray in Redacted.o
"cv::_InputArray::getUMatVector(std::vector<cv::UMat, std::allocator<cv::UMat> >&) const", referenced from:
vtable for cv::_InputOutputArray in Redacted.o
ld: symbol(s) not found for architecture armv7

Updated by Alessandro Trebbi almost 11 years ago

Ok.
you can link against several versions of stl, with little differences, maybe you are using the wrong one ( i'll check in your project );
while xcode 5.1 has some additional issues that i'm fixing with another ticket ( but it's working now on my laptop, and i will submit PR asap )

Updated by Ehren Metcalfe almost 11 years ago

:/ Initially, it appears the above testcase isn't an issue with a minimal project. Once I can sort out the issue with my own project I will post more details and (hopefully) cancel this ticket.

Updated by Ehren Metcalfe almost 11 years ago

I resolved this by deleting all frameworks from all targets in my proect and re-adding. Excuse the noise but thanks for your help Alessandro.

  • Status changed from New to Cancelled

Updated by Alessandro Trebbi almost 11 years ago

Maybe was related to framework order in your xcode project, then.

Updated by Papoj Thamjaroenporn over 10 years ago

Hello,

I have just started using OpenCV2 as a framework for iOS development since last week (although I have been using OpenCV libraries for about a year). I have encountered this very error regarding undefined symbols of getMatVector and getMatUVector:

Undefined symbols for architecture arm64:
"cv::_InputArray::getMatVector(std::vector<cv::Mat, std::allocator<cv::Mat> >&) const", referenced from:
vtable for cv::_InputOutputArray in openCVUtils.o
"cv::_InputArray::getUMatVector(std::vector<cv::UMat, std::allocator<cv::UMat> >&) const", referenced from:
vtable for cv::_InputOutputArray in openCVUtils.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I am building OpenCV2 framework based on the tutorial given on the documentation page on OS X Mavericks 10.9 and my deployment target is iOS 6.1. My experience with the installation went smoothly without the workaround mentioned above. Furthermore, I tried creating a separating, smaller iOS Xcode project that used the same portion of OpenCV code (K-means Clustering, specifically), and I was able to compile and run the project without issues. On the other hand, my bigger iOS project ran into these undefined symbols error. Commenting out the same portion of code did not produce the error.

I also tried deleting all frameworks and re-adding them, but did not work. Any help is really appreciated. Thank you!

  • Status changed from Cancelled to Open

Updated by Papoj Thamjaroenporn over 10 years ago

Cancelled again since I found a way to resolve this issue, and it does not really have to do with OpenCV2 framework itself. However, I would like to share what I found that helps me resolve it, and you can find it here.

  • Status changed from Open to Cancelled

Also available in: Atom PDF