Search code examples
macosg++iostreamclang++

iostream not found with g++ and clang on macos


I'm trying to compile StegHide from source and I got an error message, saying that iostream can't be found.

I wrote the following program and compiled it with -std set to all standards that my system has:

#include <iostream>
int main() {return 0;}

This gives this error message:

test.cpp:2:10: fatal error: 'iostream' file not found
    1 | #include <iostream>

The /Library/Developer/CommandLineTools/usr/include/c++/v1 dir only contains the __cxx_version file. Is there anything I need to (re)install?

Edit: iostream was in /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/, but how can I make g++/clang search this path by default?


Solution

  • You need to use xcode-select to activate one of the toolchains. If the libraries are not installed then you need to run xcode-select --install command.

    More details in Xcode stops working after set "xcode-select -switch"