Search code examples
c++clangllvmclang++

How do I change Clang's default include path on Windows


I failed to find system interal header files (like <iostream>).

I can pass arguments to compile every time, but is there a way to change the default includes?

C:\WINDOWS\system32>clang++ -v -c -xc++ nul
clang version 16.0.0 (https://github.com/llvm/llvm-project.git e529c0a2a03fb4eb0ddffafe0ddc7a02059f74cc)
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: D:\languages\LLVM\bin
 (in-process)
 "D:\\languages\\LLVM\\bin\\clang++.exe" -cc1 -triple x86_64-pc-windows-msvc19.31.31107 -emit-obj -mrelax-all -mincremental-linker-compatible --mrelax-relocations -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name nul -mrelocation-model pic -pic-level 2 -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -mllvm -treat-scalable-fixed-error-as-warning -v "-fcoverage-compilation-dir=C:\\WINDOWS\\system32" -resource-dir "D:\\languages\\LLVM\\lib\\clang\\16.0.0" -internal-isystem "D:\\languages\\LLVM\\lib\\clang\\16.0.0\\include" -internal-isystem "D:\\program tools\\Microsoft\\VC\\Tools\\MSVC\\14.25.28610\\include" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.19041.0\\ucrt\\" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.19041.0\\um" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.19041.0\\shared" -fdeprecated-macro "-fdebug-compilation-dir=C:\\WINDOWS\\system32" -ferror-limit 19 -fmessage-length=120 -fno-use-cxa-atexit -fms-extensions -fms-compatibility -fms-compatibility-version=19.31.31107 -std=c++14 -fdelayed-template-parsing -fcxx-exceptions -fexceptions -fcolor-diagnostics -faddrsig -o nul.o -x c++ nul
clang -cc1 version 16.0.0 based upon LLVM 16.0.0git default target x86_64-pc-windows-msvc
ignoring nonexistent directory "D:\program tools\Microsoft\VC\Tools\MSVC\14.25.28610\include"
ignoring nonexistent directory "C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\ucrt\"
ignoring nonexistent directory "C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\um"
ignoring nonexistent directory "C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\shared"
#include "..." search starts here:
#include <...> search starts here:
 D:\languages\LLVM\lib\clang\16.0.0\include
End of search list.

just want to change these default nonexistent directory (I built clang from source)


Solution

  • The trick I use with GCC, which should also work with Clang, is using the environment variables C_INCLUDE_PATH/CPLUS_INCLUDE_PATH for compiler include paths and LIBRARY_PATH for linker library paths.