简体   繁体   中英

Trouble compiling code from LLVM Kaleidoscope tutorial

When I used g++ -std=c++17 toy.cpp -o toy to compile the toy.cpp file without the header #include "llvm/ADT/STLExtras.h" in the toy.cpp file, everything was fine and I produced a "working" binary file.

However, when I added the #include "llvm/ADT/STLExtras.h" line to the toy.cpp file and compile it with the command g++ -std=c++17 toy.cpp -o toy , the terminal crushed me with the following output:

-bash: llvm-config: command not found
toy.cpp:1:10: fatal error: 'llvm/ADT/STLExtras.h' file not found
#include "llvm/ADT/STLExtras.h"

The same thing still happens even if I used "clang++ -g -O3 toy.cpp llvm-config --cxxflags --ldflags --system-libs --libs core -o toy" instead of "clang++ -g -O3 toy.cpp llvm-config --cxxflag " in the tutorial. My guess is that there's something wrong with the llvm-config thing. It's been bothering me for a while, please teach me how to solve it.

Link to the toy.cpp code

The answer to this is "llvm-config" is not working as expected.

Just check with which llvm-config to figure out whether you got this program. (mine is /usr/local/opt/llvm@8/bin/llvm-config ). Or you can install with brew install llvm .

By the way, I came up with the same issue lately on kaleidoscope tutorial (ch2), but I want to know why the #include "llvm/ADT/STLExtras.h fails after several attempts on $(llvm-config --cxxflags --ldflags) , etc or we aren't able to compile following chapter's code simply by removing the header declaration when llvm include files are necessary.

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