[SOLVED] Linker errors with OpenCV 64bits

Hi all!

I’m trying to submit an app that uses OpenCV. I’ve been trying with OF 0.9 Apothecary from GitHub and i can compile an emptyExample just fine but i get a bunch of linker errors when i add OpenCV.
I’ve added the libs in the "Build Phases -> Link Binary With Libraries” and the paths in “Linking -> Other Linker Paths”, but it makes no difference. Am i missing something? Is there another step i should be making? Or is it an issue with the OpenCV libraries not being compatible with 64bits?

Thanks in advance!!!

Try this branch:
// Edit: Try Master branch now

Includes iOS OpenCV 2.4.9 for the latest architectures and all the rest.

Let me know if that has any issues.

thanks a lot. Will give it a try and report later :wink:

These changes are in the the master branch now, you can try that.

Get this error:

ld: 64-bit LDR/STR not 8-byte aligned: from __ZN2cv7compareERKNS_11_InputArrayES2_RKNS_12_OutputArrayEi (0x100661428) to l173@0x0001E3D8 (0x100D3625C) in ‘__ZN2cv7compareERKNS_11_InputArrayES2_RKNS_12_OutputArrayEi’ from addons/ofxOpenCv/libs/opencv/lib/ios/opencv_core.a(arithm.cpp.o) for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

This sounds related to this:

The following should solve it.

This actually seems to hide the actual problem: the fact that your LLVM compiler may not choose a proper standard C++ library for compiling by default. You should go to

Project (or your Target) -> Build Settings -> Apple LLVM 6.0 - Language - C++ -> C++ Standard Library

and make sure that you pick libc++ as your choice, not just Compiler Default, since modern OpenCV library is linked against libc++. This will solve your problem without having to add the extra libc++.dylib. Including libc++.dylib framework as a workaround will not always work out if your Compiler Default actually does not choose libc++ library!

Hi. Just letting you know that everything is working with the version @danoli3 recommended (both the apothecary one and the new master branch).
I just added the ofxOpenCV source to my project, added the opencv include file to the header search path and then added all opencv libraries (the .a files) to the “link binary with libraries” in the build phases.

All working! Thanks :slight_smile:

thanks for finding the fix @danoli3
is this something we could add to the template settings? having libc++ explicitly set?

Might be good to open a Github issue for it?

Thanks!!
Theo

are u sure? valid architectures is arm64?

my setting here is libc++,and c++11,the error is still,i have used Apothecary/0.9.0 without opencv for two months.

The template iOS project has the new settings by default. I think this is being an issue for those that created the project pre-merge from the older template and trying to apply it to the new updates.

Definitely worth an issue with the fix detailed.

Hey @danoli3 thanks so much for the hard work on getting a lot of the issues fixed for ios 64 bit compatibility. I’m having one issue when trying to compile an empty app generated from the project generator. I compiled all the libraries with apothecary as instructed here:

https://github.com/openframeworks/openFrameworks/pull/3651

But I get these two errors in Xcode. Any ideas?

Undefined symbols for architecture armv7:
OBJC_CLASS$_ALAssetsLibrary”, referenced from:
objc-class-ref in opencv_highgui.a(cap_ios_video_camera.mm.o)
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)

http://imgur.com/V4Ahn82

Let me know if I can provide anymore information. Thanks in advance for any tips!

undefined symbols are usually a sign that you are using some library or framework but not linking to it, and in your case, it would appear to be the AssetsLibrary framework is used by Open CV. Searching the web with the error text:
Undefined symbols for architecture armv7: "OBJCCLASS_$_ALAssetsLibrary"
offers more detail :wink:.

Hi Jodi,

You need to add the AssetsLibrary framework to the “Link Binary With Libraries” build phase of your App target.

This is a requirement for OpenCv to link against this framework

That should fix it

@pizthewiz @danoli3 Thanks so much, I was able to compile! Thanks again for the help and hard work, its much appreciated :smile:

@tsin I recently discovered this is related to building with an older Xcode than Xcode 6.3.1. You will have to upgrade in order to support arm64