解决qt程序的链接阶段出现 undefined reference 错误

错误的原因是我使用到了 QT Widgets 模块中的东西,但是makefile的链接的参数中没有 widgets。其实官网上提到了这个:

http://doc.qt.io/qt-5/qtwidgets-index.html

解决的方法是手动修改你的 .pro 文件,在里面添加下面这句:

QT += widgets

如果出现类似的 undefined reference 这种错误应该也是在程序的链接阶段没有找到相应的函数或方法,解决方法也应该类似。

原文地址:https://www.cnblogs.com/vanwoos/p/5360051.html