[在Mac上构建我的库突然因XCode版本11.3(11C29)而失败。
我能够隔离一个问题:
似乎当您在同一函数中使用sin和cos时,优化器将使用__sincosf_stret一次计算两者。
所以我做了什么:
#import <Foundation/Foundation.h>
#include <cmath>
void coordinateCalculator(float angle, float radius, float& x, float& y) {
float mySin = sin(angle);
float myCos = cos(angle);
x = radius * myCos;
y = radius * mySin;
}
int main(int argc, const char * argv[]) {
@autoreleasepool {
float myAngle = 0.0;
float theX, theY;
float radius = 100.0;
while (myAngle < 360.0) {
coordinateCalculator(myAngle, radius, theX, theY);
NSLog(@"My coordinates: %f, %f",theX,theY);
myAngle += 1.0;
}
}
return 0;
}
在Debug中构建可以正常工作,为配置文件(带有优化的发行版)构建将失败,并显示以下错误消息:
Undefined symbols for architecture x86_64:
"___sincosf_stret", referenced from:
coordinateCalculator(float, float, float&, float&) in main.o
_main in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
我正在与:
当我将部署目标更改为10.7时,找到了sincosf_stret,但出现2个ARC错误:
Undefined symbols for architecture x86_64:
"_objc_loadClassref", referenced from:
__ARCLite__load() in libarclite_macosx.a(arclite.o)
"_objc_readClassPair", referenced from:
__ARCLite__load() in libarclite_macosx.a(arclite.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
玩部署SDK给我:
我不敢相信不可能在一个函数中使用sin / cos。因此,我希望有人能解决此问题。
谢谢,
Rudi
重新安装XCode解决了我的问题。另一位开发人员在他的系统上对其进行了尝试,并且似乎可以正常工作。这使我决定删除XCode并重新安装。现在问题解决了。 XCode本身没有问题。