Week 7: OpenCV Meets the iPhone

April 18, 2010

Compiler flags, cross-compiling, versions, static linking, simulator vs. device—it’s tricky.

Useful links about building OpenCV for other platforms and linking to the library:

It seems that dynamic linking with a private .framework doesn’t work and OpenCV only works linked as a static library.

With all the given work what had to be done:

  1. Build OpenCV-2.0.0 for iPhone OS 3.1 (simulator and device) according to this good tutorial.
  2. Under Target > Build > Linking > Other Linker Flags (These flags are passed with all linker invocations. [OTHER_LDFLAGS]) add Build Setting Conditions for Any iPhone Device/Any Architecture and Any iPhone OS Simulator/Any Architecture. Add the flags -lstdc++, -lz, $(SRCROOT)/OpenCV/opencv_{device,simulator}/lib/libcv.a and libcxcore.a
  3. Under Target > Build > Search Paths > Header Search Paths (This is a list of paths to folders to be searched by the compiler for included or imported header files when compiling C, Objective-C, C++, or Objective-C++. Paths are delimited by whitespace, so any paths with spaces in them need to be properly quoted. [HEADER_SEARCH_PATHS, -I]) add Build Setting Conditions for Any iPhone Device/Any Architecture and Any Iphone OS Simulator/Any Architecture. Add the path $(SRCROOT)/OpenCV/opencv_{device,simulator}/include without recursive flag.
  4. #import <opencv/cv.h>

Other option is adding headers to project and #import "cv.h".

The compiler threw some linking warnings like ld: warning: can't add line info to anonymous symbol __ZN2cv9ExceptionD1Ev.lsda from /Users/raff/Development/Durchblick/OpenCV/opencv_simulator/lib/libcxcore.a(lib_cxcore_la-cxmathfuncs.o) when building for the simulator which I couldn’t solve. I guess I simply could’ve ignore them. When using the precompiled lib there were no warnings.

Advertisements

Comments are closed.

%d bloggers like this: