c++ - 使用 LLVM 时的链接器错误
问题描述
我正在尝试使用 LLVM 构建编译器后端,但我陷入了链接器错误。目前我试图做的只是包括 LLVMContext.h (我正在做IBM 教程),但这给了我以下链接器错误:
$ g++ -o compiler *.o -L/home/jakob/llvm2/lib/*.a -lantlr4-runtime
BayesBaseListener.o:(.data.rel+0x0): undefined reference to `llvm::DisableABIBreakingChecks'
collect2: error: ld returned 1 exit status
Makefile:2: recipe for target 'compiler' failed
make: *** [compiler] Error 1
知道如何正确配置 LLVM 以免发生这种情况吗?
解决方案
选项-L
是添加链接器用于搜索库的路径。选项-l
(小写 L)是告诉链接器与特定库链接。
但是,对于您的情况,如果您想链接特定位置的所有静态库,只需将库文件列为输入文件:
g++ -o compiler *.o /home/jakob/llvm2/lib/*.a -lantlr4-runtime
请注意,我不使用该-L
选项。
推荐阅读
- delphi-5 - Delphi 5 - 舍入到小数点后 4 位异常
- javascript - 如何从 GeoJSON 对象中获取特定值
- python - 使用 connexion 和 swagger 制作的速率限制 REST API
- amazon-cloudformation - 如何更改导入资源的 DeletionPolicy 以便后续导入工作?
- android - 如何开发一个使用 VPN api 检索所有浏览信息的安卓应用程序?
- angular - 角度选择更改事件 - 类型“EventTarget”上不存在属性“值”
- r - 找出不同组内方差最大的变量
- swift - 为 Int 编写一个计算属性。迅速
- java - 添加填充有文本的 JTextArea/JTextPane 时防止 JSscrollPane 调整大小
- javascript - 迁移到 Firebase Admin SDK 后 Firebase 实时数据库规则出现问题