Linker Errors After Upgrading Xcode to 4.5.2 and OpenCV to 2.4.3

My project worked perfectly until this morning. I used xcode 4.3 and an older version of OpenCV (I'm not sure about the exact version). OSX was already 10.7.x but not 10.7.5


Today, after updating OSX to 10.7.5, xcode to 4.5.2 and downloading OpenCV 2.4.3, I get the following linker errors when trying to build a project:

Undefined symbols for armv7 architecture:
"_OBJC_CLASS _ $ _ ALAssetsLibrary" referenced by:
objc-class-ref in opencv2 (cap_ios_video_camera.o)
"cv :: FeatureDetector :: create (std :: string const &)" referenced by:
- [ImageAnalyzer detectBlobs:] in ImageAnalyzer.o
"cv :: FeatureDetector :: detect (cv :: Mat const &, std :: vector> &, cv :: Mat const &) const" referenced:
- [ImageAnalyzer detectBlobs:] in ImageAnalyzer.o
ld: character not found for armv7 architecture
clang: error: linker command did not work with exit code 1 (use -v to call the call)

To use the new opencv structure, I removed the link to the old framework and referenced the project on the previously prepared opencv2.framework, downloaded from here .
I also removed the link to libz.dylib and added the link to libC ++. Dylib .
The last step was to update the prefix file to a new structure. The corresponding part in the prefix file now looks like this:

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

It all narrowed down to these 4 linker errors that I can't get rid of. I tried using libstdc ++. Dylib , but I get even more errors. I also tried to create OpenCV myself, as explained here , but I still get the same errors as the pre-built infrastructure.


What am I missing? Is there anything else I need to change in my project?




UPDATE:
As you can see here , setting the "C ++ standard library" to "libC ++ (LLVM C ++ standard libray with C ++ 11 support" gave only one error:

clang: error: invalid deployment target for -stdlib = libC ++ (requires iOS 5.0 or later)

Changing the deployment target on iOS 5 finally launched my project.
Does this mean that OpenCV 2.4.3 does not work on iOS versions older than 5?

+5
ios xcode opencv linker-errors
Dec 25 '12 at 12:11
source share
7 answers

Since I cannot get an answer regarding the versions (neither here, nor on the OpenCV Q & A website), I am going to post this as an answer, since it at least solved the problem. This is described here .


In your Build Settings project, go to the Apple LLVM 4.1-Language Compiler section.
There:
Set C ++ Dialog Language to Default Compiler
Install C ++ Standard Libray on libC ++ (LLVM C ++ standard libray with C ++ 11 support


After doing the above, I stopped getting these linker errors and received only one error, which stated that only iOS 5 and above was supported. Change The goal of deploying to 5.0 in the summery project did the trick.


In conclusion, I'm still not sure what this means regarding compatibility with OpenCV 2.4.3 with iOS versions older than 5 years.

+4
Dec 27 '12 at 11:39
source share

steps to compile and run C ++ opencv 2.4.4 on mac os x lion 10.7.5 with cmake 2.8.10 and xcode 4.6.1

Availability of necessary tools

Use cmake to compile opencv

  • go to the extracted opencv folder
  • create assembly directory

     mkdir build cd build cmake -D WITH_TBB=OFF -D BUILD_NEW_PYTHON_SUPPORT=OFF -D BUILD_FAT_JAVA_LIB=OFF -D BUILD_TBB=OFF -D BUILD_EXAMPLES=ON -D CMAKE_CXX_COMPILER=g++ CMAKE_CC_COMPILER=gcc -D CMAKE_OSX_ARCHITECTURES=x86_64 -D BUILD_opencv_java=OFF -G "Unix Makefiles" .. make -j8 sudo make install 
  • from the build folder, go to bin / and run one of the tests

     ./opencv_test_stitching 

Create your own c ++ opencv xcode project

  • run xcode and create a new xcode project
  • select command line tool for project type under os x
  • open the project build settings.
  • in the Architecture section, set Architecture to 64-bit intel. also set valid architectures to x86_64
  • in the "Assembly Options" section, set the compiler for the default C / C ++ compiler
  • In Search Paths, set header search paths to / usr / local / include
  • also in the "Search Paths" section, set the library search paths to / usr / local / lib
  • in the Apple compiler LLVM 4.2 - Language Suite Standard C ++ library for libstd ++ (for OpenCV 2.4.6, Xcode 5, LLVM 5.0 and 10.8.5 set the dialect and std library for both languages ​​to "Default compiler instead" libstd ++ ")

Add compiled opencv libraries to your project

  • go to the "Construction Phases" tab next to the "Settings" tab in which you were:
  • inside Link Binary With libraries, click the + sign and select Add Other
  • press the forward slash / on the keyboard and type / usr / local / lib
  • press enter and select the libraries you want to use in your project.
  • make sure you always choose libopencv_core.2.4.4.dylib
  • press enter and you will see the selected dylib under your project.

write code

  • first organizes the files, right-click the icon of your project and select "New Group"
  • enter a new opencv group or something else
  • drag and drop dylib and drop them into this group.
  • open main.cpp
  • copy the code from any of the test tests that come with opencv and paste it here.
  • make sure that all necessary dylibs are added, for example, if you copied opencv_test_stitching.cpp code into main.cpp, you will need to add the following libraries in the previous steps libopencv_core.2.4.4.dylib libopencv_highgui.2.4.4.dylib libopencv_stitching.2.4.4 .dylib

Greetings.

+6
Mar 27 '13 at 15:37
source share

It seems your AssetsLibrary structure is missing from your project.

  • Select the top node in the project navigator. (The project and goals page appears with the build settings.)

  • Choose a goal.

  • Select Summary.

  • Scroll down to Linked Framework and libraries.

  • Click the Plus icon at the end of the table and select "AssetsLibrary.framework".

  • Click Add.

Then try creating it again.

+4
Dec 25 '12 at 12:41
source share

clang: error: invalid deployment target for -stdlib = libC ++ (requires iOS 5.0 or later) to remove this error.

GoTo BuildSettings. Install the default C ++ library for the default compiler. the error will be deleted of course.

+1
Mar 25 '13 at 10:36
source share

Just to get it in messages somewhere if someone else comes across the same. If you follow all the great tips on how to create an appropriate C ++ library to create an iOS application, but still get link errors for undefined characters, make sure your code files are configured to compile as C ++! This rename your .m to .mm and .h to .hpp. These are trifles ...

+1
May 11 '13 at 19:33
source share

Instead of using the terminal commands specified in the opencv installation guide on the official website, use the following commands to create opencv from the terminal. Worked for me.

cd OpenCV-2.3.1

mkdir build

cd build

cmake -G "Unix Makefile" ..

to do

sudo make install

0
Jan 13 '14 at 7:18
source share
  • Go Xcode / General / Related Structures and Libraries
  • Click the "+" button
  • Type: AssetsLibrary
  • Select "AssetsLibrary.framework" and import it

Done

Good luck

0
Jun 07 '17 at 9:33 on
source share



All Articles