Query regarding LLVM library for compilation

Dear LLVM Team

I have installed LLVM and have also tried of using examples for learning LLVM.
I am really sorry if this is a silly question but I tried writing one file for clang++ which uses some header file from LLVm nad clang like verifier.h.
I could not compile as the error was thrown that verifier.h not found even when I have the exact path. But when I put my file in example folder and made changes to makefile and build the examples by running make file everything just worked fine. My query is is ther any way that my system automatically finds the header for LLVm and clang whenever I use them like it does for stdio.h and iostream.h or I need to build the example again and again ?

Thanks and Regards

The tool llvm-config [1] might solve your problem, it will give you
the correct compiler and linker flags. Just make sure the llvm-config
you invoked is the right one.


[1] http://llvm.org/docs/CommandGuide/llvm-config.html

Dear Nitin,

The LLVM and Clang header files #include other LLVM and Clang header files. Therefore, when compiling your code with gcc or clang, you need to add the -I option to tell the compiler where to find these header files. The -I option can be used multiple times to specify multiple locations for which to look for header files.

For example, if a header file is located in /u/criswell/foo/bar.h, then adding -I/u/criswell to the gcc/clang command line will allow me to use #include <foo/bar.h> in my source code.

The reason why your code compiles when added to the LLVM/Clang source trees is that the LLVM Makefiles add the appropriate -I options for you.


John Criswell