0

I'm trying to compile a code snippet that uses llvm as c++ library but I'm getting errors such as the compiler could not find header files.

The compiler commands I used are:

clang++ file.cpp -o reader `llvm-config --cxxflags --libs --ldflags --system-libs`

and

clang++ file.cpp -o reader `llvm-config --cxxflags --libs --ldflags --system-libs` -v -fno-exceptions

I've also tried to specify the include directory:

clang++ parser.cpp -o reader `llvm-config --cxxflags --libs --ldflags --system-libs` -v -fno-exceptions -I$(llvm-config –includedir)

and with specifying manually the path to the lib. However, nothing was successful. It seems that I should install llvm as library apart from it being installed as a tool - but I can't find any reasonable description on how to do it.

If I'm right and it should be somehow installed, I would appreciate your help for explaining how to do that. If it shouldn't and you can see any other issue that is preventing me from compiling the code, I would appreciate your help in that. Thanks in advance!

Polina F.
  • 1
  • 1
  • have you checked what `llvm-config --cxxflags --libs --ldflags --system-libs` returns? Please show the code that is producing the error and the exact error messages – Alan Birtles Jan 09 '23 at 08:15
  • As I'm new to llvm usage, I've tried to compile the code from the answer to this question (https://stackoverflow.com/questions/30195204/how-to-parse-llvm-ir-line-by-line) "as-is". And I'm getting the next error: "file.cpp:7:10: fatal error: 'llvm/Bitcode/ReaderWriter.h' file not found" – Polina F. Jan 09 '23 at 08:32
  • @AlanBirtles, the command mentioned returned: -I//lib/llvm-10/include -std=c++14 -fno-exceptions -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -L//lib/llvm-10/lib -lLLVM-10 – Polina F. Jan 09 '23 at 08:38
  • But --system-libs is empty – Polina F. Jan 09 '23 at 09:46

0 Answers0