14

Like previously referred here, ___sincos_stret can not be found when compiling a project that uses this symbol using the Xcode5 command line tools.

In the above referenced thread a solution is posted for IOS targets (passing -miphoneos-version-min=5.0 to the compiler), is there a solution for desktop (x64) targets?

It for example happens for me when trying to compile polycode.

Edit 2:

Strangely, after compiling the libraries referenced in the previous error manually, the error now happens to be located in lto.o, which is an internal llvm header itself...

undef: ___sincos_stret
Undefined symbols for architecture x86_64:
  "___sincos_stret", referenced from:
      _mdct_init in lto.o
      _dradfg in lto.o

I'm running OSX 10.9 DP with Xcode 5. This is the link step.

Community
  • 1
  • 1
Appleshell
  • 7,088
  • 6
  • 47
  • 96

4 Answers4

14

stret is Apple-speak for "returns a structure". ___sincos_stret is an LLVM optimisation — if you write code that calls sin(n) and then cos(n) and uses both results then the compiler will make one call to the structure-returning sincos method, receiving a structure with both things in it. It's faster to work out both at once rather than individually if the operand is the same.

On a superficial browsing I can't see a sin or cos in initInterTab2D but I expect something is being inlined.

While poking around I tried:

cd /Applications/Xcode.app/Contents/Developer/Platforms 
grep -lr ___sincos_stret *

Via that and using nm on likely results, I found the ___sincos_stret function is exposed in both iOS since 7.0 and OS X since 10.9 as part of their libsystem_m.dylibs. E.g. if your Xcode is installed in the default place, try:

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

And/or:

nm /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/lib/system/libsystem_m.dylib | grep sincos

You'll see the symbol in either of those. So the correct solution would be to set an older deployment target in Xcode, or do the equivalent in your makefile.

Tommy
  • 99,986
  • 12
  • 185
  • 204
  • I'm pretty sure I build for OSX. I use a cmake file from a project and compile the project with make. I'll add one of the errors in the question. – Appleshell Sep 26 '13 at 10:34
  • 1
    The `__sincos_stret` symbol is provided by `/usr/lib/system/libsystem_m.dylib` on OS X, just like iOS. The questioner’s issue is that the compiler is generating the symbol in one or more object files because no targeted OS version is specified in the compile step (so it defaults to the host system version), but the link step is specifying an OS version < 10.9, on which the symbol is not available. – Stephen Canon Sep 26 '13 at 21:35
  • @StephenCanon 10.9 being the beta version currently under NDA, right? So I failed to find the symbol because I don't have the beta SDK, but it's already substituted by the compiler because a lot of other people do? – Tommy Sep 26 '13 at 21:43
  • The compiler shouldn't be generating it unless it’s running on a system that has it and macosx-version-min is set to a system that has it (or not specified). – Stephen Canon Sep 26 '13 at 21:46
  • @Adam S - Stumbled into this from a completely different angle: trying to get matplotlib to work in Python. Partly confirms Stephen Canon's assessment. When it tries to get some matrix transform code, it blows up during the load (of a package called "update_path_extents"), looking for an unresolved ref. to "___sincos_stret" in /usr/lib/libSystem.B.dylib. Sadly for me too "the trail has gone cold" and I have no clue how to fix it :-( – Howard Pautz Nov 25 '13 at 23:44
6

You want -mmacosx-version-min=10.8 (or whatever your targeted OS version is).

Stephen Canon
  • 103,815
  • 19
  • 183
  • 269
  • 1
    This seems to make sense, but even if I add the argument to CXXFLAGS in every cmake command the error persists. I may be doing something wrong though - [this is my current make procedure for this case](http://pastebin.com/J7qmNegN) (can't currently test with other projects). – Appleshell Sep 26 '13 at 22:01
  • Have you tried using the curses based interface `ccmake`? – Gerard Apr 26 '14 at 10:56
  • 1
    Just ran into this when linking to ICU for a project using an older OS X SDK. What worked was to build ICU with both `-isysroot` and `-mmacosx-version-min` set in `CPPFLAGS` **and** `LDFLAGS`. – Eric3 Mar 04 '15 at 04:55
3

It seems like un- and reinstalling Xcode5 DP and the OSX 10.9 command line tools solved the problem. I guess there was a problem with updating from the previous versions.

Appleshell
  • 7,088
  • 6
  • 47
  • 96
  • @trojanfoe Because this is what fixed the problem. – Appleshell Oct 09 '13 at 17:54
  • Please, could you elaborate a little on how you "un-installed" Xcode and the CL tools? Did you simply delete Xcode and re-install it or did you have to do anything else? – Chris Oct 29 '13 at 13:23
  • It worked for me as well, just install Xcode 5.1DP from the Apple dev center and run "xcode-select -s /Applications/Xcode51-DP.app/Contents/Developer/" once you did it if you want to put the configuration back to original, you can just run "xcode-select --reset". – foOg Nov 26 '13 at 14:24
  • Yep, this worked for me too (Mavericks user). I simply searched for XCode in the App Store and installed it. Although something seemed to be up with the App Store because it didn’t show any progress info for download or install and then, eventually, it was just magically done. –  Apr 23 '14 at 19:40
2

Open the following file in a text editor /opt/local/etc/macports/macports.conf and add there a lines like

# MACOSX_DEPLOYMENT_TARGET - osx version to be compatible with earlier OSX version.
macosx_deployment_target            10.8
MACOSX_DEPLOYMENT_TARGET            10.8
vy32
  • 28,461
  • 37
  • 122
  • 246