简体   繁体   中英

LLVM header not found after apt-get install

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?

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, ie:

clang++ -g -O3 toy.cpp `llvm-config --cxxflags --ldflags --system-libs --libs core` -o toy

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM