c++macoszshmacos-sequoia

macOS Sequoia 15.4.1: Compiled C++ binary instantly killed on run (zsh: killed)


I recently upgraded to Sequoia 15.4.1 on my Macbook, and now I'm running into an issue where even trivial c++ binaries get automatically killed by the operating system. Here is the trivial c++ file:

#include <iostream>

int main() {
    std::cout << "test!\n";

    return 0;
}

When I run g++ test.cpp && ./a.out I get the following error:

% ./a.out
zsh: killed     ./a.out

I thought it was because a.out wasn't signed, but that doesn't seem to be the case. My trivial C++ program just gets killed without any explanation.

Has anyone run into this recently? It started happening after I upgraded my OS so I think it has to do with the new MacOS version.


Solution

  • I figured it out! This line was in my zshrc. For whatever reason, g++ was using the iOS toolchain instead of the macOS one. I have no idea who set that or why.

    export SDKROOT=$(xcrun --sdk iphoneos --show-sdk-path)
    

    Upon removing it, everything started working again.