title: How to install header files in cpp
body: <p>This is a similar problem to <a href="https://stackoverflow.com/questions/43376386/how-to-install-clang-header-files">How to install clang header files?</a> but I was unable to make a comment or ask a question because it requires 50+ reputation. Please excuse the duplication.</p>
  
  <p>I have clang installed on my MacOS (in /usr/bin/clang ) which I think comes installed by default on Mac, however, when I try to include clang header files in a cpp file, it says they are not found</p>
  
  <p><code>/Users/jzhu/go/src/github.com/codelingo/sandbox/test/cpp/main.cpp:7:10: fatal error: 'clang/AST/ASTConsumer.h' file not found #include &lt;clang/AST/ASTConsumer.h&gt;
           ^
  1 error generated</code></p>
  
  <p>Question: is it necessary (and possible, if so, how) to install the header files when clang is already installed and built on the MacOS system (or does clang itself need to be reinstalled at the same time as all the desired development tooling packages and their header files are installed)?</p>
  
  <pre><code>#include &lt;clang/AST/ASTConsumer.h&gt;
  #include "clang/AST/RecursiveASTVisitor.h"
  #include "clang/Frontend/CompilerInstance.h"
  #include "clang/Frontend/FrontendAction.h"
  #include "clang/Tooling/Tooling.h"
  </code></pre>
  
  <p>I have used the "&lt;>" suggested by @ nurmurat in <a href="https://stackoverflow.com/questions/43376386/how-to-install-clang-header-files">How to install clang header files?</a> but it does not solve the problem.</p>
  
  <p>The clang packages can be found in /Users/username/ccompiler/llvm/tools/clang/include/clang.</p>
  
  <pre><code>$ pwd
  /Users/username/ccompiler/llvm/tools/clang/include/clang
  $ ls 
  ARCMigrate      Basic           Driver          FrontendTool        Rewrite         Tooling
  AST         CMakeLists.txt      Edit            Index           Sema            module.modulemap
  ASTMatchers     CodeGen         Format          Lex         Serialization
  Analysis        Config          Frontend        Parse           StaticAnalyzer
  </code></pre>
  
  <p>I have also tried to make a copy of this clang folder and included in my project, but it ends up with a similar error when clang/AST/RecursiveASTVisitor.h has a line #include "clang/AST/Attr.h"</p>
  
  <p>I was trying to follow this example <a href="http://clang.llvm.org/docs/RAVFrontendAction.html" rel="nofollow noreferrer">http://clang.llvm.org/docs/RAVFrontendAction.html</a></p>
  
  <p>In my project folder, I have a main.cpp with the same content as the tutorial in the link above and a CMakeList.txt which is created automatically by CLION</p>
  
  <pre><code>cmake_minimum_required(VERSION 3.8)
  project(cpp)
  
  set(CMAKE_CXX_STANDARD 17)
  
  set(SOURCE_FILES main.cpp)
  add_executable(cpp ${SOURCE_FILES})
  include_directories(${LLVM_INCLUDE_DIRS})
  </code></pre>
  
  <p>PS: I followed <a href="https://clang.llvm.org/get_started.html" rel="nofollow noreferrer">https://clang.llvm.org/get_started.html</a> to install the clang. </p>
  
  <pre><code>$ clang --version
  Apple LLVM version 8.1.0 (clang-802.0.42)
  Target: x86_64-apple-darwin16.7.0
  Thread model: posix
  InstalledDir: /Library/Developer/CommandLineTools/usr/bin
  </code></pre>