Sample Header Ad - 728x90

How to compile C++ program on macOS?

0 votes
1 answer
58 views
My macOS version is:
$ uname -a
Darwin nanxiaos-MacBook-Pro.local 24.5.0 Darwin Kernel Version 24.5.0: Tue Apr 22 19:54:26 PDT 2025; root:xnu-11417.121.6~2/RELEASE_ARM64_T8112 arm64
I wrote a simple C++ program:
$ cat foo.cc
#include 

int main() {
    return 0;
}
But the compiler can't find the related header files:
$ c++ foo.cc
foo.cc:1:10: fatal error: 'vector' file not found
    1 | #include 
      |          ^~~~~~~~
1 error generated.
Per my understanding, if there is a C++ compiler installed, the related header files and libraries should be installed as well. So how to compile C++ program on macOS?
Asked by Nan Xiao (525 rep)
Aug 6, 2025, 06:32 AM
Last activity: Aug 6, 2025, 07:22 PM