Expected in: /usr/lib/libc++.1.dylib

dyld: Symbol not found: __ZTTNSt3__114basic_ofstreamIcNS_11char_traitsIcEEEE Referenced from: /private/var/containers/Bundle/Application/19315D00-BA14-46B0-83BD-0961BBFFC9B8/VBell.app/VBell Expected in: /usr/lib/libc++.1.dylib in /private/var/containers/Bundle/Application/19315D00-BA14-46B0-83BD-0961BBFFC9B8/VBell.app/VBell

Who knows how to solve this problem?

libc++.1.dylib is Apple’s built-in C++ standard library. __ZTTNSt3__114basic_ofstreamIcNS_11char_traitsIcEEEE is some infrastructure for the basic_ofstream type:

% c++filt __ZTTNSt3__114basic_ofstreamIcNS_11char_traitsIcEEEE
VTT for std::__1::basic_ofstream<char, std::__1::char_traits<char>>

That symbol is expected to be imported from the C++ standard library. I built a small test project to try this out. Specifically:

  1. Using Xcode 15.0 on macOS 13.6.1, I created a new project from the iOS > App template.

  2. I changed the extension of ViewController.m to .mm, making it an Objective-C++ file.

  3. I expanded the -viewDidLoad method like so:

    static void test() {
        std::string filename = "/dev/stdout";
        std::ofstream ostrm(filename);
        ostrm << "Hello Cruel World!\n";
    }
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        // Do any additional setup after loading the view.
        test();
    }
    
  4. I ran it (on the sim, which is all I have available right now, but I expect this to work the same on the device) and it printed Hello Cruel World!.

  5. I then looked at the binary:

    % nm -m Test741870.app/Test741870
    …
                     (undefined) external __ZTTNSt3__114basic_ofstreamIcNS_11char_traitsIcEEEE (from libc++)
    …
    

As you can see, it’s importing the symbol from the expected place.

I’m not sure why this is failing for your project. I recommend that you repeat the above to verify my findings. Then compare your real project to your test project.

The first thing I’d look at is the deployment target. Make sure that your real project is using a reasonable deployment target. Specifically, make sure it’s deployment target is actually supported by the Xcode you’re using.

Share and Enjoy

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

hello @eskimo

I have the same error on a large project (swift, obJC, C++) when launched on MacOS 11 (Big Sur). It used to work fine, probably because I was using specific flags : -Wl -ld_classic, to target Big Sur. But these compilation options no longer work for me with Xcode 15.1 as I get another error this time

ld: unknown option: -no_warn_duplicate_libraries

It looks like the -no_warn_duplicate_libraries option is passed to the ld_classic linker and not understood by it...but I cannot control how this flag is being passed. The only way I get rid of the error is to remove the -Wl -ld_classic options from the Xcode project.

When launched on BigSur, the app crashes with the

dyld: Symbol not found: __ZTTNSt3__114basic_ofstreamIcNS_11char_traitsIcEEEE 

error. I can run

% c++filt __ZTTNSt3__114basic_ofstreamIcNS_11char_traitsIcEEEE

on that system and I get the expected result

VTT for std::__1::basic_ofstream<char, std::__1::char_traits<char>>

but it does not find the symbol when I run the app

Any idea how to solve this ?

Regards

Matt

Expected in: /usr/lib/libc++.1.dylib
 
 
Q