"Undefined symbols for architecture armv7" when importing STATIC LIBRARY that contains OPENCV functions
Asked Answered
N

2

6

I developed a very simple application, using openCV for iOS. It worked fine until I decided to use that code in another project. The new project shows this armv7 error and I can't see where the problem is (please, see the last image).

I created a static lib file with my working code, which has the following architecture info: lib architecture

Then I compiled it into a *.a file and added the dyOpenCv.a and the DyOpenCV.h files to my main project, which has the following architecture configuration: Project architecture

But when I try to use the method within the header file DyOpenCV.h I get the following errors: armv7 error

Any ideas of what may be wrong?

Niagara answered 26/4, 2013 at 15:59 Comment(1)
They are all linking problems. Make sure you link your project to the libraries that implement those symbols.Brotherhood
N
12

There were two issues related to linking libraries:

  1. Firstly, although my subproject had the opencv2.framework correctly added and linked to it, I also had to add the framework to my main project. This way I got rid of the cv::* linking problems;

  2. The second issue was related to my cross-compiling Objective-C++ configuration. Since I was using libc++ as my Standard Library, I had to add -lc++ to my Other Linker Flags. In case you are using libstdc++ as your Standard Library, you should add -lstdc++ instead.

After those changes, it all worked perfectly! Good luck!

Niagara answered 10/5, 2013 at 14:6 Comment(3)
Hey. I am facing a similar issue. And it's driving me mad. Please, how did you added the framework to your project? I tried lots of stuff found around the internet, but I always get the linker errors. Thanks in advanceKier
I don't remind this very well, but I can try sharing the details I still remember, hope it helps: I used the concept of subproject or nested project in Xcode. The subproject had a C dependency and an OpenCV dependency. I included those dependencies as libraries to both the subproject and the project.Niagara
Thank you! Will try it and then I will give a feedback wether it worked or not.Kier
D
2

I think its because ur project is not linking to the C++ runtime .

Try adding libc++.dylib to ur linked Libraries.

Dusa answered 8/5, 2013 at 13:55 Comment(1)
Hi, can you please explain how to do it? Thanks!Kier

© 2022 - 2024 — McMap. All rights reserved.