Fatal error: 'llvm/IR/Value.h' file not found on ubuntu 22.04

after installing llvm from the ubuntu packages, compiling always show “./AST.h:9:10: fatal error: ‘llvm/IR/Value.h’ file not found
#include “llvm/IR/Value.h””.
I am new to linux, can anyone help plz, thx

Did you install the llvm-dev package?

I contains the missing headers. On the bottom of the page there is a list of files button.

Yes, I have install llvm-dev. The main problem here is that the llvm and llvm-c folders are stored in include/llvm-14/ and include/llvm-c/. So if I change my code into #include “llvm-14/llvm/IR/Value.h” it would give another error: /usr/include/llvm-14/llvm/IR/Value.h:16:10: fatal error: ‘llvm-c/Types.h’ file not found #include “llvm-c/Types.h”. Shall I just cp the files out of llvm-14/ and llvm-c/ or is there a way to cover them without moving them?

I use wsl, that may be the issue

llvm-dev contains: /usr/include/llvm and
/usr/include/llvm-c. Note that there is llvm-dev and llvm-14-dev. It should suffice to do something ala
Then your compiler should find llvm and llvm-c in /usr/include.

so i should install llvm-dev instead of llvm-14-dev?

You will need both:

The llvm-dev package depends on llvm-14-dev. If you install the llvm-dev package, then it will automatically also install llvm-14-dev.

./AST.h:9:10: fatal error: ‘llvm/IR/Value.h’ file not found
#include “llvm/IR/Value.h”
1 error generated.

Still an error, sorry i am new. I have many questions.

If you installed the llvm-dev package, then you should find the Value.h file in /usr/include/llvm/IR.
Your compiler should find the file by default. Maybe you need to add -I/usr/include to the compiler flags.

The dir /usr/include/llvm/IR is empty

Stupid question. Is there a /usr/include/llvm-14/llvm/IR/Value.h file?

of course

using cppflags ‘-I /usr/include/llvm-14 /usr/include/llvm-c-14’ makes the error
/usr/include/llvm-14/llvm/IR/Value.h:16:10: fatal error: ‘llvm-c/Types.h’ file not found
#include “llvm-c/Types.h”
1 error generated.
make: *** [makefile:11: scanner.yy.o] Error 1
that i have mentioned before

Could you try `-I/usr/include/llvm-14 -I/usr/include/llvm-c-14’? Note that there are two -Is.

it worked, thanks!

sorry that i may wasted your time on a simple question