Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install clang header files?

Tags:

c++

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 script, it says they are not found

Example.cpp:1:10: fatal error: 'clang/Driver/Options.h' file not found

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)?

#include "clang/Driver/Options.h"
#include "clang/AST/AST.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/ASTConsumer.h"
#include "clang/AST/RecursiveASTVisitor.h"
#include "clang/Frontend/ASTConsumers.h"
#include "clang/Frontend/FrontendActions.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Tooling/CommonOptionsParser.h"
#include "clang/Tooling/Tooling.h"
#include "clang/Rewrite/Core/Rewriter.h"
like image 912
Leahcim Avatar asked Apr 12 '17 17:04

Leahcim


People also ask

Where does Clang look for header files?

Some header files ( stddef. h , stdarg. h , and others) are shipped with Clang — these are called builtin includes. Clang searches for them in a directory relative to the location of the clang binary.

How do I install the latest Clang?

Enter the command clang --version to see if the Clang compilers are already installed. If you want to install or update the Clang compilers, enter the command command xcode-select --install The following pop-up windout should appear on your screen (in this example I have placed it withing the Terminal window).


1 Answers

When you use double quotes for including the libraries it will search the current directory which your c/cpp file or application resides in. Try with < and > or compile with the -I option

like image 81
nurmurat Avatar answered Sep 23 '22 16:09

nurmurat