首页 > 解决方案 > 如何使用 llvm::cl::ParseCommandLineOptions> - 链接错误

问题描述

我正在尝试使用 llvm::cl 来解析命令行参数。首先,我正在尝试编写一个简单的驱动程序,通过 llvm::cl::ParseCommandLineOptions 从命令行解析输入文件。

#include "llvm/Support/CommandLine.h"
int main(int argc, char *argv[]) {

    llvm::cl::ParseCommandLineOptions(argc, argv, "quad2bitcode generator\n");
    llvm::cl::opt<std::string> InputFilename(llvm::cl::Positional,
                                             llvm::cl::desc("<input file>"),
                                             llvm::cl::Required);
    ...

编译时,我收到以下链接错误。任何帮助将不胜感激!

Undefined symbols for architecture x86_64:
  "__ZTIN4llvm2cl18GenericOptionValueE", referenced from:
      __ZTIN4llvm2cl15OptionValueCopyINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEE in quadreader.cpp.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status

标签: llvmllvm-ir

解决方案


推荐阅读