5

我已经成功编译了LLVM kalidoscopeC 中的示例。

现在我正在扩展代码:

#include "llvm/Support/CommandLine.h"

static cl::opt<std::string> InputFilename(cl::Positional, cl::desc("<input file>"), cl::Required);

int mail(...

现在我编译使用:

clang++ -g toy.cpp llvm-config --cppflags --ldflags --libs all-O3 -o toy

在此更改之后,我收到以下错误:

Undefined symbols for architecture x86_64: "typeinfo for llvm::cl::GenericOptionValue", referenced from: typeinfo for llvm::cl::OptionValueCopy<std::string> in toy-Pq1GSI.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

可能出了什么问题,我该如何解决?

版本:

clang++ -v Apple clang version 4.1 (tags/Apple/clang-421.11.66) (based on LLVM 3.1svn) Target: x86_64-apple-darwin12.2.0 Thread model: posix


brew info llvm llvm: stable 3.2 (bottled), HEAD http://llvm.org/ /usr/local/Cellar/llvm/3.2 (628 files, 106M) * https://github.com/mxcl/homebrew/commits/master/Library/Formula/llvm.rb
==> Options
--all-targets   Build all target backends
--universal     Build a universal binary
--rtti  Build with C++ RTTI
--shared    Build LLVM as a shared library
--with-clang    Build Clang C/ObjC/C++ frontend
==> Caveats Extra tools and bindings are installed in /usr/local/Cellar/llvm/3.2/share/llvm and /usr/local/Cellar/llvm/3.2/share/clang.
4

1 回答 1

-1

似乎将编译命令更改为此是一个修复:

clang++ -g toy.cpp llvm-config --cxxflags --ldflags --libs -O3 -o toy
于 2019-01-22T09:20:44.563 回答