6 Replies
      Latest reply on Jan 24, 2020 6:27 AM by rbartels
      rbartels Level 1 Level 1 (0 points)

        Building my libraries on Mac suddenly started to fail with XCode Version 11.3 (11C29).

        I was able to isolate one problem:


        It seems that when you use sin and cos in the same function, the optimizer will use __sincosf_stret to calculate both at once but this result in a link error.


        So what did I do:

        1. Create a new XCode project, cmd line tool, objectiv-c
        2. Change the main.m to main.mm to allow C++
        3. Change main as:
        #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[])
            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;

        I'm using in my project:

        • C++: C++14, libC++
        • Base SDK: MacOS
        • Deployment target 10.14


        Building in Debug works fine, building for profiling (Release version with optimization) will fail giving the following error message:


        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


        When I change the deployment target to 10.7, the sincosf_stret is found, but I get 2 ARC errors:


        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


        Trying different deployment targets give:

        • 10.7: 2 ARC link errors
        • 10.10: 2 ARC link errors AND _sincosf_ret error
        • 10.12 or higher: _sincosf_ret error


        I can't belief that it is not possible to use sin/cos in one function. So I hope someone has a hint to resolve this problem. I have to build multiplatform libraries. It worked fine for years. Recently I switched to XCode 11 and to BaseSDK "MacOS". Before I used some special tool to reinstall BaseSDK 10.7 for XCode 9. I wanted to get rid of the necessety of using this special tool for reinstalling BaseSDK 10.7 after each XCode update.