anirudh anirudh - 1 year ago 236
C++ Question

LLVM header not found after apt-get install

I am new to llvm and clang. I installed

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
and hence all the files were installed in directories ending with
. Can anyone tell me how to fix this error without having to remove the installation and do a manual build install from the llvm source.

Thanks in advance

Answer Source

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
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download