Clang Doesn't See Basic Headers

Clang doesn't see basic headers

Point 3 solved the problem for me.

1.
Had the same issue, fedora 21::clang 3.5.0:

clang++ -std=c++14 -pedantic -Wall test_01.cpp -o test_01 -v

2.

ignoring nonexistent directory "/usr/lib/gcc/i686-redhat-linux/4.9.2/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/usr/bin/../lib/clang/3.5.0/include
/usr/include
End of search list.
test_01.cpp:1:10: fatal error: 'iostream' file not found
#include <iostream>

3.

sudo yum install gcc-c++

4.

#include "..." search starts here:
#include <...> search starts here:
/bin/../lib/gcc/i686-redhat-linux/4.9.2/../../../../include/c++/4.9.2
/bin/../lib/gcc/i686-redhat-linux/4.9.2/../../../../include/c++/4.9.2/i686-redhat-linux
/bin/../lib/gcc/i686-redhat-linux/4.9.2/../../../../include/c++/4.9.2/backward
/usr/local/include
/usr/bin/../lib/clang/3.5.0/include
/usr/include
/usr/lib/gcc/i686-redhat-linux/4.9.2/include
End of search list.

clang/clang++ doesn't find C/C++ headers in windows?

Try this one

Installing Clang 3.5 for Windows.

Regards.

Clangd not finding standard headers

I figured it out thanks to "How to use clang with mingw-w64 headers on windows".

Using the llvm prebuilt binaries, clangd looks for MSVC libraries, which I did not have; I use the MinGW compilers.

To have clangd look for the header files in the appropriate location, where the MinGW standard header files are located, I needed to include the compiler option:

--target x86_64-pc-windows-gnu

in the compiler_flags.txt or compile_commands.json file.

Clang-Tidy can't find my header files

This answer will only help you if you use CMake to manage your project.

CMake has an option to create a .json file that contains all the compiler calls with command line options. This file can be given to clang-tidy with the option:

-p <build-path> is used to read a compile command database.

For example, it can be a CMake build directory in which a file named
compile_commands.json exists (use -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
CMake option to get this output). When no build path is specified,
a search for compile_commands.json will be attempted through all
parent paths of the first input file . See:
http://clang.llvm.org/docs/HowToSetupToolingForLLVM.html for an
example of setting up Clang Tooling on a source tree.

As the documentation states, you have to set the CMAKE_EXPORT_COMPILE_COMMANDS variable to generate the .json file with CMake and then pass the CMake output directory to clang-tidy.
Clang-tidy will then get the include paths from the commands in the .json file.

Why doesn't Clang come with standard library headers?

The standard library is NOT part of the compiler itself. It is part of the runtime environment on a particular platform. Sure, some organisations put together a "kit" with all the necessary parts to build an application - there may even be someone that packages a Clang compiler with a suitable runtime.

In general, you should be able to download the Windows SDK and get the relevant header files there - and if you use clang-cl, it should be largely compatible with the MSVC compiler [or provide clang or clang++ with the correct -fms-compatibility or whatever it is called].

Or as suggested in the other answer, use libcxx, but it's not 100% complete for Windows.



Related Topics



Leave a reply



Submit