LLVM 教程 --system-libs 不存在
LLVM tutorial --system-libs does not exist
我一直在研究 LLVM 的 Kaleidoscope 教程,但在编译它时遇到了无穷无尽的问题。在下面的教程中,对于 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.
我一直在研究 LLVM 的 Kaleidoscope 教程,但在编译它时遇到了无穷无尽的问题。在下面的教程中,对于 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.