Where is /usr/lib/libc++.1.dylib and how to deploy it?

As I want to use a c++ 17 feature which is only available in clang 15.0. I upgrade my macos to 14.5 and xcode to 15.2. My app works fine in my development machine, when I run it in lower version of macos with lower version of xcode/clang, I got error: cant' load library ***, Symbol not found :yyyy. referenced from : zzz, Expected in: /usr/lib/libc++.1.dylib

When I check /usr/lib/, I can't find libc++.1.dylib.

Normally in Linux, this could be solved by shipping libstdc++.so.6 or static linkling the libstdc++ library, as I'm a newbie in macos, what's the recommend way to solve it in macos ? Thanks!

Did you set your deployment target to encompass those older systems?

In general, Xcode tries to ensure that, if you set your deployment target correctly, things will either work or you’ll get build-time complaints about the fact that your code is relying on functionality that’s not available on those systems.

Normally in Linux

A lot of things work differently on Apple platforms (-: I have a post that explains a bunch of this: An Apple Library Primer. In terms of C++ runtime libraries, third-party program have two options:

  • Use the system C++ runtime libraries and write code that’s compatible with the program’s minimum deployment target.

  • Use their own C++ runtime libraries, and then bundle that with the program.

Notably, you can’t bundle the system’s C++ runtime libraries with your code. In fact, these libraries don’t even exist on disk any more because they’re glommed into the dynamic linker shared cache:

% ls -l /usr/lib/libc++.1.dylib
ls: /usr/lib/libc++.1.dylib: No such file or directory
% dyld_info -platform /usr/lib/libc++.1.dylib
/usr/lib/libc++.1.dylib [arm64e]:
    -platform:
        platform     minOS      sdk
           macOS     14.4      14.4   
     MacCatalyst     17.4      17.4   

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Where is /usr/lib/libc++.1.dylib and how to deploy it?
 
 
Q