如何使用 clang++ 构建 llvm 示例的 ModuleMaker

How to build llvm example's ModuleMaker by using clang++

本文关键字:ModuleMaker llvm 何使用 clang++ 构建      更新时间:2023-10-16

我正试图从LLVM示例构建ModuleMaker。

当我调用时:

clang++ -g ModuleMaker.cpp `llvm-config --cppflags --ldflags --libs core jit native` -o ModuleMaker

我收到错误消息:

/home/huangered/Desktop/ModuleMaker/main.cpp:59: undefined reference to `llvm::WriteBitcodeToFile(llvm::Module const*, llvm::raw_ostream&)'
clang: error: linker command failed with exit code 1 (use -v to see invocation)

我该怎么解决这个问题?

clang++ main.cpp `llvm-config --cppflags --ldflags --libs core jit native bitwriter` -o main

好的,我明白了。我应该在llvm配置中添加一个bitwriter组件。