3

I'm trying to use a C++ static library into my iPhone app which uses a modified version of OpenCV for iOS and I'm stuck with this issue at linking time:

Undefined symbols for architecture armv7:
  "___sincos_stret", referenced from:
      cv::initInterTab2D(int, bool) in opencv2(imgwarp.o)
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I really do not understand what I'm missing, that function does not seem to be present in OpenCV and I do not find anything meaningful on the web; I'm wondering if it's in some mathematical library, but I haven't found anything yet.

I've compiled OpenCV with Clang and using the default libc++ library.

The libmylibrary.a and the OpenCV2 framework are correctly in the list of linked libraries.

I'm new to XCode, therefore I could have missed something trivial in the compilation of the static library and/or in the linking of it into my project.

I haven't changed the source code of that object as my changes were related to another part of the imgproc module of OpenCV, therefore I guess that this could have happen even using the default version.

Do you have any clues?

Aurelius
  • 11,111
  • 3
  • 52
  • 69
Marco Bonifazi
  • 623
  • 2
  • 8
  • 10
  • Do you have the XCode dev preview installed? And how are you building the OpenCV library? – Aurelius Jul 09 '13 at 16:32
  • I'm using XCode 4.6.3 but I've tried the XCode 5-DP3, no success in both cases, although with the latter I have the crash at runtime. I'm building the OpenCV library using the python script provided in the source code as it's written in the readme.txt under the platforms/ios directory. – Marco Bonifazi Jul 09 '13 at 16:38

4 Answers4

4

For fixing this problem with the Xcode 5 toolchain I specified the minimum supported iOS version as a compiler option to match the configuration in Xcode. For example:

-miphoneos-version-min=5.0

You can add this to the C and CXX flags in the makefile

CFLAGS += -miphoneos-version-min=5.0
CXXFLAGS += -miphoneos-version-min=5.0
ulcica
  • 478
  • 5
  • 15
3

For those who don't want to build with lower version of XCode, try changing python build script of OpenCV iOS. In build_framework.py, I added IPHONEOS_DEPLOYMENT_TARGET=6.0 in lines and rebuilt OpenCV for iOS.

os.system("xcodebuild -parallelizeTargets ARCHS=%s -jobs 8 -sdk %s -configuration Release -target ALL_BUILD" % (arch, target.lower()))
os.system("xcodebuild ARCHS=%s -sdk %s -configuration Release -target install install" % (arch, target.lower()))

to get

os.system("xcodebuild IPHONEOS_DEPLOYMENT_TARGET=6.0 -parallelizeTargets ARCHS=%s -jobs 8 -sdk %s -configuration Release -target ALL_BUILD" % (arch, target.lower()))
os.system("xcodebuild IPHONEOS_DEPLOYMENT_TARGET=6.0 ARCHS=%s -sdk %s -configuration Release -target install install" % (arch, target.lower()))

For me that fixed the issue. A nice read on the symbol __sincos_stret

TODO: Though that fixes the issue, in OpenCV.xcodeproj (in build folder) generated from the python script, it still has deployment target as iOS 7.0. There might be a cleaner way.

Community
  • 1
  • 1
kiranpradeep
  • 10,859
  • 4
  • 50
  • 82
1

I ran into this problem after installing the XCode 5 developer preview and building OpenCV with the build_framework.py script. ___sincos_stret appears to be coming from using the new compiler version.

I fixed this problem by changing the path to the command-line tools.

In Terminal, verify the XCode command-line path:

xcode-select --print-path

If it prints a path inside XCode5-DP.app, then switch to the tools for Xcode 4:

xcode-select --switch /Applications/XCode.app/Contents/Developer

And rebuild the framework. Then try recompiling the project.

Aurelius
  • 11,111
  • 3
  • 52
  • 69
  • This fixes the issue, you were totally right. Summarizing: it seems that there's an issue on XCode 5-DP3 and the compilation of OpenCV with the related tools. To fix it you must launch Aurelius's commands and then rebuild OpenCV, the static library and the iPhone project from scratch with the tools of XCode 4. I'd like to know why I was getting that issue, but I'm quite happy with the fix, of course. – Marco Bonifazi Jul 09 '13 at 17:38
0

Per a quick search in support of Adam's question elsewhere, the symbol is defined in [path to SDK]/usr/lib/system/libsystem_m.dylib. Proof:

nm /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/usr/lib/system/libsystem_m.dylib | grep sincos

Rather than sticking to old versions of the tools or SDK, just make sure you're linking against that.

Tommy
  • 99,986
  • 12
  • 185
  • 204