2 Replies
      Latest reply: Nov 4, 2016 2:31 AM by NorbertSchneider RSS
      NorbertSchneider Level 1 Level 1 (0 points)

        Hi,

        I compile some c++ on 10.12 with xc8 which uses boost. It's supposed to run starting 10.9, so I used the current 10.12 SDK + deployment target 10.9.

        (-mmacosx-version-min=10.9)

         

        However, the program runs on 10.12 only, because it tries to lazy link clock_gettime, which was introduced in 10.12.

        My code compiles against the 10.11 SDK unchanged, which is my workaround right now.

        So:

        * I thought a deployment_target would avoid such situations. Is this wrong? What precisely does it do then?

        * Do I need to build against a old 10.x SDK if I want to have programs running on old 10.x?

        Thanks.

        • Re: clock_gettime
          eskimo Apple Staff Apple Staff (7,925 points)

          It should be possible to use clock_gettime when it’s available and fall back to some other clock when it’s not.  If you look in the 10.12 SDK, you’ll see that this routine is decorated with the __CLOCK_AVAILABILITY macro, which expands to various platform availability macros including __OSX_AVAILABLE(10.12).  Thus, if you set your deployment target you’ll link to this call weakly.

          For that to work the calling code has to:

          • check for the presence of the routine

          • use it if it’s present

          • implement a fallback if it’s not

          You’ll find more details on how to do this is the SDK Compatibility Guide.

          You haven’t posted any details as to how your code deals with this aspect of the problem, so it’s hard to say what’s going wrong here.

          Share and Enjoy

          Quinn “The Eskimo!”
          Apple Developer Relations, Developer Technical Support, Core OS/Hardware
          let myEmail = "eskimo" + "1" + "@apple.com"

            • Re: clock_gettime
              NorbertSchneider Level 1 Level 1 (0 points)

              Thanks for the link to the SDK guide, thats what I was hoping for. My own code actually never calls clock_gettime, so I guess the problem lies within boost. I just checked, both my build and my build of boost use the deployment target, so I guess boost gets it wrong, I'll dig into that direction.

               

              Solved for me, thanks again,