LLVM 教程 --system-libs 不存在

LLVM tutorial --system-libs does not exist

本文关键字:不存在 --system-libs 教程 LLVM      更新时间:2023-10-16

我一直在研究LLVM的万花筒教程,并且在编译它时遇到了无穷无尽的问题。 在下面的教程中,似乎 llvm-config 不存在标志"--system-libs"(它只是打印出一个使用块)。 我尝试将其排除在外,但它似乎是链接器错误的兔子洞,这让我相信我刚刚设置了完全错误的开发环境。 我已经在OSX Yosemite和Ubuntu上尝试过,结果相似。 未找到的错误可以通过添加 -I [llvm 路径] 来解决,但这只会暴露更多错误,使我认为这是错误的方法。

http://llvm.org/releases/3.6.0/docs/tutorial/LangImpl3.html

$make
#clang++ -g -v -L -std=c++11 -O3 toy.cpp -I/usr/include/llvm-3.5/ `llvm-config --cxxflags --ldflags --libs all` -o toy
clang++ -g -O3 toy.cpp `llvm-config --cxxflags --ldflags --system-libs --libs core` -o toy
usage: llvm-config <OPTION>... [<COMPONENT>...]
Get various configuration information needed to compile programs which use
LLVM.  Typically called from 'configure' scripts.  Examples:
  llvm-config --cxxflags
  llvm-config --ldflags
  llvm-config --libs engine bcreader scalaropts
Options:
  --version         Print LLVM version.
  --prefix          Print the installation prefix.
  --src-root        Print the source root LLVM was built from.
  --obj-root        Print the object root used to build LLVM.
  --bindir          Directory containing LLVM executables.
  --includedir      Directory containing LLVM headers.
  --libdir          Directory containing LLVM libraries.
  --cppflags        C preprocessor flags for files that include LLVM headers.
  --cflags          C compiler flags for files that include LLVM headers.
  --cxxflags        C++ compiler flags for files that include LLVM headers.
  --ldflags         Print Linker flags.
  --libs            Libraries needed to link against LLVM components.
  --libnames        Bare library names for in-tree builds.
  --libfiles        Fully qualified library filenames for makefile depends.
  --components      List of all possible components.
  --targets-built   List of all targets currently built.
  --host-target     Target triple used to configure LLVM.
  --build-mode      Print build mode of LLVM tree (e.g. Debug or Release).
Typical components:
  all               All LLVM libraries (default).
  engine            Either a native JIT or a bitcode interpreter.
toy.cpp:1:10: fatal error: 'llvm/IR/Verifier.h' file not found
#include "llvm/IR/Verifier.h"
         ^
1 error generated.
make: *** [parser] Error 1

事实证明,我正在使用的llvm-config版本已经过时了。 在 Ubuntu 上我可以apt-get install llvm-config-3.6,在 OSX 上我可以做一个brew install homebrew/versions/llvm36。 最后使用 llvm-config-3.6 而不仅仅是 llvm-config。