Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
264 views
in Technique[技术] by (71.8m points)

c++ - ___sincos_stret undefined symbol when linking

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...