55

When I am trying to sourceCpp, it gives a warning:

ld: warning: text-based stub file /System/Library/Frameworks//CoreFoundation.framework/CoreFoundation.tbd and library file /System/Library/Frameworks//CoreFoundation.framework/CoreFoundation are out of sync. Falling back to library file for linking.

But the function actually works. Just wondering how to solve this warning.

Paulo Mattos
  • 18,845
  • 10
  • 77
  • 85
MOOn
  • 651
  • 1
  • 5
  • 4
  • 3
    This seems to be a common problem since a certain XCode update. I've encountered it myself when compiling C++ code. It is discussed on the Apple forums, but I haven't tried out their solution: https://forums.developer.apple.com/thread/97850 – merlinND Jul 13 '18 at 15:51

7 Answers7

39

Using MacOS Mojave 10.14.2, the fix for me was to use the solution from this comment on GitHub:

export SDKROOT=macosx10.14

Put the line above in your ~/.bash_profile. Replace 10.14 with your specific version of MacOSX Xcode tools. Find out what version you have by doing:

xcrun --show-sdk-path

It will print something like:

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk

Just grab the last word, make it all lower caps and replace it in the export command above.

Update Sep 2019

In the latest release, they removed the version number from the sdk. Just grab the full path and export it as SDKROOT, like this:

export SDKROOT="/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk"

Update Aug 2021

To avoid having to continuously update the exported value whenever you upgrade your OS, you can place the xcrun command directly in the shell script:

export SDKROOT=$(xcrun --show-sdk-path)
Paul Razvan Berg
  • 16,949
  • 9
  • 76
  • 114
13

I had this problem while compiling Go code on my Mac too.

The tld files were out of sync in /System/Library/Frameworks/.

The solution:

Just links the recent frameworks from MacOSX.sdk to /Library/Frameworks/

sudo ln -s  /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/CoreFoundation.framework /Library/Frameworks/CoreFoundation.framework
Stephen Rauch
  • 47,830
  • 31
  • 106
  • 135
jiyongdong
  • 350
  • 3
  • 7
  • 4
    This removed the warnings I was seeing with MacOS High Sierra (10.13.6) and XCode 10.1. Reinstalling xcode CLI did not fix it for me. I needed to link a lot of frameworks. Here's the [script](https://gist.github.com/wawiesel/eba461de5f5e38f7f0ac93ae3676b484). – wawiesel Nov 08 '18 at 00:45
  • The script posted by @redwizard792 fixed almost all warnings. One more link from `PrivateFrameworks` helped: `sudo ln -s /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/PrivateFrameworks/UIFoundation.framework /Library/Frameworks` – merlinND Nov 17 '18 at 16:48
  • @redwizard792 The script fixed most of the warnings for me as well except for the file `TrustEvaluationAgent`. Thanks – solalito Dec 06 '18 at 13:03
  • FWIW, this solution caused a link error: `ld: in '/Library/Frameworks//CoreFoundation.framework/Versions/A/CoreFoundation.tbd', file was built for unsupported file format ( 0x2D 0x2D 0x2D 0x20 0x21 0x74 0x61 0x70 0x69 0x2D 0x74 0x62 0x64 0x2D 0x76 0x33 ) which is not the architecture being linked (x86_64): /Library/Frameworks//CoreFoundation.framework/Versions/A/CoreFoundation.tbd for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)` – Seth Johnson Jan 22 '19 at 23:26
6

Edit: this seems to have stopped working post 10.13.16. Trying it will not hurt your mac after the re-install but i'm not sure how to fix it going forward.

Came across this recently, just remove the command line tools for mac and re-install.

$ rm -rf /Library/Developer/CommandLineTools
$ xcode-select --install

After these steps you will see a pop to install the new version of the tools.

Highstead
  • 2,291
  • 3
  • 26
  • 30
  • 16
    The above isn't working for me. Does anyone have other ideas on how to fix this? I've uninstalled xcode & tools. Then re-installed and I still get the same error. It seems to be causing configure to fail thinking a library isn't installed. ld: warning: text-based stub file .../Foundation.tbd and library file .../Foundation are out of sync. Falling back to library file for linking. ld: warning: text-based stub file ...CoreFoundation.tbd and library file ...CoreFoundation are out of sync. Falling back to library file for linking. – Marty Sep 12 '18 at 06:49
3

Reinstalling may help, but also may not.

It's Apple's fault and they need to fix it with another command line tools update.

Just ignore the warning for now.

(See a bunch of other people experiencing the issue here: https://github.com/vim/vim/issues/3445 and here: https://github.com/golang/go/issues/26073)

UberFarmer
  • 39
  • 1
  • 2
0

I think this has nothing to do with Rcpp.

This is related to your system.

I show first lines of one tbd file below. It is just a text file. You can open it using a text editor.

--- !tapi-tbd-v3
archs:           [ i386, x86_64, x86_64h ]
uuids:           [ 'i386: 17321B27-67AB-3D26-B9DF-A69624B1C82B', 'x86_64: 358C547D-E227-3228-8218-62327F4605C8', 
                   'x86_64h: 945E5C0A-86C5-336E-A64F-5BF06E78985A' ]
platform:        macosx
install-name:    /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
current-version: 1452.23
compatibility-version: 150
exports:         
  - archs:           [ i386 ]
    symbols:         [ '$ld$add$os10.5$.objc_class_name_NSObject', '$ld$add$os10.6$.objc_class_name_NSObject', 
                       '$ld$add$os10.7$.objc_class_name_NSObject', '$ld$hide$os10.4$.objc_class_name_NSArray', 
                       '$ld$hide$os10.4$.objc_class_name_NSCalendar', '$ld$hide$os10.4$.objc_class_name_NSData', 
...

As I understand, the tbd file contains the version and location of the real library file. It is like a "link". (Just my personal understanding. Please correct me if this is wrong.)

After the upgrade of Xcode, your tbd file and real library are out of sync. Then you got the warning.

I think you can ignore this warning for now, since your compiler has fallen back and found the correct library.

Qiang Kou
  • 522
  • 4
  • 8
0

The dates of CoreFoundation and CoreFoundation.tbd show that the latter is much older. This suggests it can be ignored. The out of sync problem can easily be cured by deleting the .tbd file. It is not needed and if not present cannot generate the out of sync error.

I use CoreFoundation and IOKit on 10.13.6 and this is a simple solution avoiding reloading CommandLine tools or setting links or trying to export SDKs etc.

John

John
  • 1
0

If you previously set SDKROOT in your ~/.bash_profile or ~/.zshrc you either need to update it whenever you update macOS or delete (if you do not need it).

This was the case for me export SDKROOT=macosx10.14 was in my ~/.bash_profile, after I updated to macOS Catalina 10.15.7 so it was causing the problem.

If you choose to update, it will look like this (based on previous answers)

export SDKROOT="/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk"
papigee
  • 6,401
  • 3
  • 29
  • 31