6

When compiling a c++ project in a conda environment on MacOS Big Sur, the error ld: unsupported tapi file type '!tapi-tbd' in YAML file may occur. How to proceed?

thomaskeefe
  • 1,900
  • 18
  • 19

2 Answers2

5

On Big Sur, the SDK that comes with Command Line Tools is too new. An older one needs to be downloaded and used:

  1. Download the 10.10 SDK "MacOSX10.10.sdk.tar.xz" from here.
  2. Extract it: tar xf MacOSX10.10.sdk.tar.xz -C /opt
  3. Add following lines to ~/.condarc:
conda_build:
  config_file: ~/.conda/conda_build_config.yaml
  1. create ~/.conda/conda_build_config.yaml if it doesn't exist and add:
CONDA_BUILD_SYSROOT:
  - /opt/MacOSX10.10.sdk        # [osx]

Many thanks to ihnorton on this thread.

thomaskeefe
  • 1,900
  • 18
  • 19
  • 1
    I was a bit skeptical about this, particularly because it is such an old version of the SDK. However, looking into how Conda Forge builds their `osx-64` packages, I found [they are currently downloading SDK 10.9](https://github.com/conda-forge/conda-forge-ci-setup-feedstock/blob/master/recipe/download_osx_sdk.sh). So, yes this appears to just be how things are. – merv Sep 19 '21 at 18:07
  • 2
    I used 10.10 because this [thread](https://github.com/ContinuumIO/anaconda-issues/issues/9096) says that is what the anaconda team is targeting (in 2018), but there are also suggestions there that newer SDK versions work too, e.g. up to 10.13 – thomaskeefe Sep 19 '21 at 20:08
  • @rmwenzel no, you're right - it's flexible infrastructure; however, Conda Forge still targets 10.9 in its package recipes. e.g., [Conda Forge pinning settings](https://github.com/conda-forge/conda-forge-pinning-feedstock/blob/7bdadae1184906d8fb8b0d2943b2cd1579267a77/recipe/conda_build_config.yaml#L109). – merv Apr 05 '22 at 17:27
  • 1
    Woops, I deleted my comment, for the record, I was saying that the conda recipe @merv linked to used whatever SDK was installed but defaulted to 10.9. And yeah, looks like Conda Forge targets 10.9, while [Anaconda targets 10.10](https://docs.conda.io/projects/conda-build/en/latest/resources/compiler-tools.html#macos-sdk) as OP mentioned. – rmwenz Apr 05 '22 at 22:27
  • 1
    Also FWIW I got the same error as OP trying to install packages in RStudio. In case anyone else has the same issue, you may need to update `.Rprofile` with `Sys.setenv(CONDA_BUILD_SYSROOT = "/opt/MacOSX10.10.sdk")`, as a [comment](https://github.com/ContinuumIO/anaconda-issues/issues/9096#issuecomment-705130399) at the [GitHub issue thread](https://github.com/ContinuumIO/anaconda-issues/issues/9096) referenced in this answer indicates. – rmwenz Apr 05 '22 at 22:31
  • 1
    Or just `export CONDA_BUILD_SYSROOT="/opt/MacOSX10.10.sdk"` in your terminal config file, e.g.`.bash_profile` or `.zshrc` – rmwenz Apr 05 '22 at 22:53
  • 1
    Hi, I tried to export new link and create `~/.conda/conda_build_config.yaml`. But both do not work. Old link to SKD still appear. `ld: unsupported tapi file type '!tapi-tbd' in YAML file '/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib/libm.tbd' for architecture x86_64` – Binh Thien Apr 27 '22 at 02:51
1

Alternatively, if you don't want to build against conda (but just happen to be in a conda environment), you may be unwittingly using a conda-distributed ld that's incompatible with the newer system tools and libraries.

If your $PATH is set up so that Anaconda's ld has higher preference over the system linker, this will explain it:

$ which -a ld
/blah/anaconda3/bin/ld
/usr/bin/ld

If that's the case, reorder your PATH to put anaconda's directory after /usr/bin. Then, which ld should point to the system ld, and you should be good to go.

Seth Johnson
  • 14,762
  • 6
  • 59
  • 85