xcode ___sincos_stret 链接时未定义的符号

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19015780/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 03:55:15  来源:igfitidea点击:

___sincos_stret undefined symbol when linking

c++xcodemacosxcode5

提问by Appleshell

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

就像前面提到的here___sincos_stret使用Xcode5命令行工具编译使用这个符号的项目时找不到。

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

在上面引用的线程中,针对 IOS 目标发布了解决方案(传递-miphoneos-version-min=5.0给编译器),是否有针对桌面 ( x64) 目标的解决方案?

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

例如,当我尝试编译polycode时就会发生这种情况。

Edit 2:

编辑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...

奇怪的是,在手动编译上一个错误中引用的库之后,错误现在恰好位于lto.o 中,它本身就是一个内部 llvm 头文件...

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.

我正在使用 Xcode 5 运行 OSX 10.9 DP。这是链接步骤

采纳答案by Appleshell

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.

似乎取消并重新安装 Xcode5 DP 和 OSX 10.9 命令行工具解决了这个问题。我猜从以前的版本更新有问题。

回答by Tommy

stretis Apple-speak for "returns a structure". ___sincos_stretis 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.

stret是 Apple 所说的“返回结构”。___sincos_stret是一种 LLVM 优化——如果你编写的代码调用sin(n)然后cos(n)使用这两个结果,那么编译器将调用一个返回结构的 sincos 方法,接收一个包含这两个东西的结构。如果操作数相同,则同时计算比单独计算更快。

On a superficial browsing I can't see a sinor cosin initInterTab2Dbut I expect something is being inlined.

在肤浅的浏览中,我看不到 asincosininitInterTab2D但我希望有一些东西被内联了。

While poking around I tried:

在四处闲逛时,我尝试了:

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

Via that and using nmon likely results, I found the ___sincos_stretfunction 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在可能的结果上使用,我发现该___sincos_stret函数自 7.0 以来在 iOS 和自 10.9 以来的 OS X 中都作为其libsystem_m.dylibs 的一部分公开。例如,如果您的 Xcode 安装在默认位置,请尝试:

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.

您会在其中任何一个中看到符号。因此,正确的解决方案是在 Xcode 中设置较旧的部署目标,或者在您的 makefile 中执行等效操作。

回答by Stephen Canon

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

您想要-mmacosx-version-min=10.8(或您的目标操作系统版本是什么)。

回答by user2850498

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

在文本编辑器中打开以下文件 /opt/local/etc/macports/macports.conf 并添加如下几行

# MACOSX_DEPLOYMENT_TARGET - osx version to be compatible with earlier OSX version.
macosx_deployment_target            10.8
MACOSX_DEPLOYMENT_TARGET            10.8