关于llvm教程中Kaleidoscope的编译问题

About the compilation problem of Kaleidoscope in llvm tutorial

我正在学习 llvm。

我正在尝试编译 Kaleidoscope 教程 3.6 中的代码。 https://llvm.org/docs/tutorial/LangImpl03.html

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

我遇到了一些错误,但我不知道该怎么办。

clang++.exe: error: unsupported option '--cxxflags'
clang++.exe: error: unsupported option '--ldflags'
clang++.exe: error: unsupported option '--system-libs'
clang++.exe: error: unsupported option '--libs'
clang++.exe: error: no such file or directory: 'llvm-config'
clang++.exe: error: no such file or directory: 'core -o'
clang++.exe: error: no such file or directory: 'toy'

对了,我是在Windows下编译的。

您收到此错误的主要原因是您的 shell 没有正确解释您的命令。

参见:

clang++.exe: error: no such file or directory: 'llvm-config'

因此应该传递给 llvm-config 的标志被传递给 clang.exe。

参见:

clang++.exe: error: unsupported option '--cxxflags'
clang++.exe: error: unsupported option '--ldflags'
clang++.exe: error: unsupported option '--system-libs'
clang++.exe: error: unsupported option '--libs'

要解决此问题,请确保在您的计算机上安装 llvm-config 并确保您使用的命令行支持正确的 shell 语义。此类 shell 的示例为 git bash 或 mingw.