1

I have GCC-11.2.0 installed via homebrew on my MAC. But I found that the include path was not what I expected. enter image description here

I'd like to remove all the include paths and change it to /opt/homebrew/Cellar/gcc/11.2.0_3/include/c++/11 I've tried the answer on Change gcc include path globally but it doesn't work. enter image description here

There is nothing change to the include path. enter image description here

  • 1
    You could compile with the `--sysroot dir` option – Ted Lyngmo May 08 '22 at 19:55
  • 2
    The include paths you are showing seem to be those for C compilation only. The `/include/c++/11` path will be added if you compile C++ code. The latter is not sufficient as only include path. What problem are you actually trying to solve? – user17732522 May 08 '22 at 19:58
  • It is well known that MAC uses clang as the default compiler for C/C++, so its default include path is shown in the diagram. However, the standard library for clang is implemented differently from that for GCC, and I just want to change the default include path in the figure to /opt/homebrew/Cellar/gcc/11.2.0_3/include/c++/11. – user17132171 May 09 '22 at 02:55
  • In particular, I would like to ask in which configuration files these include paths are defined. – user17132171 May 09 '22 at 03:06
  • 1
    @user17132171 `[...]/include/c++/11` contains the C++ standard library header files. `[...]/gcc/[arch]/include` contains compiler headers (e.g. for intrinsics etc.). `[...]/usr/include` probably contains at least the C standard library headers. All of these are needed to compile a C++ program. The default search paths are built-in when compiling GCC. You may change them when using `gcc` e.g. with the flag `-nostdinc` followed by `-isystem` to specify the new paths. Maybe it is possible to use a [spec file](https://gcc.gnu.org/onlinedocs/gcc/Spec-Files.html) as well. – user17732522 May 09 '22 at 08:19

0 Answers0