如何使用Qt解决"Position Independant code"错误

How to solve "Position Independant code" error with Qt

本文关键字:Independant code 错误 Position Qt 解决 何使用      更新时间:2023-10-16

我正在尝试在debian上编译一些C /QT代码,我会得到以下错误:

/usr/include/x86_64-linux-gnu/qt5/QtCore/qglobal.h:1113:4: error: #error "You must build your code with position independent code if Qt was built with -reduce-relocations. " "Compile your code with -fPIC (-fPIE is not enough)."
# error "You must build your code with position independent code if Qt was built with -reduce-relocations. "

代码具有makefile,因此基本上只是执行make命令。

请我该怎么办来解决这个问题?预先感谢!

编辑:请找到我要编译的代码https://github.com/juliendelile/mecagen

我找到了解决问题的解决方案。

我只需要在mecagen/gui中的makefile的50行中添加-FPIC。

感谢您的帮助。