0

I am trying to run a C++ program which has following header.

#include <clang-c/Index.h>

And its main function look like this.

int main(int argc, char **argv) {
    if (argc < 2) {
        std::cerr<< "Missing argument: path to source\n";
        return -1;
    }

    CXIndex index = clang_createIndex(0, 1);
    CXTranslationUnit tu;

    .....remaining program.

I have downloaded and installed LLVM 10.0 Windows(64bit) from following link.
LLVM download link windows
Also i have downloaded and installed CMake 3.18 for Windows(64bit) from following link.
CMake download link windows
Also i have installed Visual Studio Community 15 2017.
Clang++ command works for simple C++ programs. But when i try to run my program with this header.

clang++ node.cpp

I get an error.

fatal error: 'clang-c/Index.h' file not found

I have checked that this header file is located in C:\Program Files\LLVM\include\clang-c. But when i run i get the error.
I have checked my environment variables and saw these two paths are there.

C:\Program Files\CMake\bin
C:\Program Files\LLVM\bin

I have searched a lot but did not found any solution on google for windows. Please tell me what i am doing wrong. Or if it requires a different command to run this program.

Qiniso
  • 2,587
  • 1
  • 24
  • 30

1 Answers1

1

I have checked that this header file is located in C:\Program Files\LLVM\include\clang-c.

I have checked my environment variables and saw these two paths are there.

C:\Program Files\CMake\bin
C:\Program Files\LLVM\bin

Neither of the paths you listed is the path of that header.

Anyway, you need to configure your compiler's include directories, not your system's binary PATH.

Since the code you're trying to build depends on Clang headers, I suggest that you talk to its author to find out the proper way to configure your toolchain to build that project, as there may well be other things that you are missing. Don't try to guess at it.

Asteroids With Wings
  • 17,071
  • 2
  • 21
  • 35
  • yes those two were added automatically when i installed llvm and cmake. I added the path where that file is to the environment variables but it didn't solve the issue. Also it only includes this one clang header. – Arslan Khan Oct 02 '20 at 12:06
  • Include paths don't go in environment variables. Look up how to configure include paths for your compiler. (I linked to some resources on that topic.) – Asteroids With Wings Oct 02 '20 at 12:12