Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LLVM header not found after apt-get install

Tags:

c++

llvm

clang++

I installed llvm and clang 3.9 along with all the other packages using the below command as given in LLVM Nightly packages link.

sudo apt-get install clang-3.9 clang-3.9-doc llvm-3.9 llvm-3.9-dev llvm-3.9-doc llvm-3.9-examples llvm-3.9-runtime clang-format-3.9 python-clang-3.9 libclang-common-3.9-dev libclang-3.9-dev libclang1-3.9 libclang1-3.9-dbg libllvm-3.9-ocaml-dev libllvm3.9 libllvm3.9-dbg lldb-3.9 lldb-3.9-dev liblldb-3.9-dbg

Then I tried to compile and run the sample lexer and parser for kaleidoscope language according to this tutorial.

However, I am not able to compile the given sample program, because I get the error:

clang++-3.9 -g -O3 toy.cpp
toy.cpp:1:10: fatal error: 'llvm/ADT/STLExtras.h' file not found
#include "llvm/ADT/STLExtras.h"
         ^
1 error generated.

I think this error is because LLVM was installed as llvm-3.9 and hence all the files were installed in directories ending with *-3.9. How can I fix this error without having to remove the installation and do a manual build install from the LLVM source?

like image 698
anirudh Avatar asked Oct 28 '16 15:10

anirudh


1 Answers

That looks like a bug in the tutorial -- the code in toy.cpp used to be self-contained, but it now depends on an LLVM header (this is a recent change).

You can use the command provided in chapter 3 to build instead, i.e.:

clang++ -g -O3 toy.cpp `llvm-config --cxxflags --ldflags --system-libs --libs core` -o toy
like image 131
Ismail Badawi Avatar answered Sep 18 '22 23:09

Ismail Badawi