LLVM-5.0 MakeFile未定义的参考失败
LLVM-5.0 Makefile undefined reference fail
包括我的代码中的以下语句
main_module->dump(); // main_module is of type llvm::Module*
导致以下链接器错误:
undefined reference to 'llvm::Module::dump() const'
转储方法位于/usr/lib/llvm-5.0/include/llvm/IR/Module.h
我检查了堆栈溢出(使用llvm :: function :: dump((,Linker给出了"未定义的引用" llvm :: value :: value :: dump((const'&quort'&quort;(,当我们似乎在链接器未按正确的顺序馈送库。但是,我显然在汇编命令中最终有库:
clang++-5.0 -g -O3 main.cpp -o main llvm-config-5.0 --cxxflags --ldflags --system-libs --libs core mcjit native
任何帮助都将不胜感激。
很奇怪的是,链接器确定了转储方法的类型。它显然进入了包含文件。那么,为什么它将其称为未定义的参考?
代码我正在尝试运行:
# include "llvm/IR/LLVMContext.h"
# include "llvm/IR/Module.h"
# include "llvm/IR/IRBuilder.h"
# include <iostream>
using namespace llvm;
static LLVMContext ctxt;
static IRBuilder<> builder(ctxt);
int main(int argc, char** argv) {
Module* main_module = new Module("main_module", ctxt);
std::cout << main_module->getModuleIdentifier() << "n";
FunctionType* func_type = FunctionType::get(builder.getInt32Ty(), false);
Function* main_func = Function::Create(func_type,Function::ExternalLinkage, "main", main_module);
if (main_module->getFunction("main")) {
std::cout << "Found function!n";
}
main_module->dump(); // need this for debugging and testing reasons with LLVM
return 0;
}
除了Subrat提供的解决方案外,您还可以调整代码以避免调用dump
。您可以通过致电:
main_module->print(llvm::outs(), nullptr);
同样,如果要倾倒LLVM函数,则可以写入:
main_func->print(llvm::outs());
实际上,从LLVM 5.0.0开始,这就是实现dump()
函数的方式。
似乎dump
的定义在ASMWriter.cpp
中,似乎被剥夺了。另外,ASMWrite.cpp
的调试方法是指debug.cpp
中的CC_11
我通过复制debug.cpp
和Module::dump()
(来自asmwriter.cpp-- since我不需要整个代码,只有此文件中的特定子例程(来解决问题。
- 如果没有malloc,链表实现将失败
- 模板参数替换失败,并且未完成隐式转换
- 具有默认模板参数的多态类的模板推导失败
- 视图中的参数推导失败:take_while
- C++错误消息*成员参考.**初学者*
- 链接到自行创建的dll失败
- 带有特殊路径部分的"std::filesystem::weakly_canonical"失败
- GetShortPathName在网络驱动器上使用中文文件夹时失败
- gcc和c++17的过载解析失败
- 为什么使用 P/Invoke 调用 dll 时,某些计算机中的 LoadLibrary 失败?
- 在WSL:configure_file上对config_file的每次调用都失败:配置文件时出现问题
- 使用 GCC 卸载的 OpenMP 卸载失败,并出现"Ptx assembly aborted due to errors"
- 使用cmake从源代码构建MySQL连接器/C++失败(与以前的声明冲突)
- 在决定是通过参考还是通过价值时,尺寸真的是一个问题吗
- 链接阶段在Ubuntu上失败,但在MacOS上失败
- 从父数组测试用例构造二叉树失败
- LibGit2 SSH身份验证失败
- 如何让LLDB在成功时退出,在失败时等待
- LLVM-5.0 MakeFile未定义的参考失败
- 参考off64_t,在mingw下Qt 5的静态编译失败