问题原因
出现该问题的原因是 相关的库路径和依赖项没有设置对。
类似的错误还有
QT error: LNK2019: 无法解析的外部符号 "__declspec(dllimport) public: __cdecl QtCharts::QLineSerie
__declspec(dllimport) public: __cdecl QSerialPortInfo::~QSerialPortInfo(void)" (__imp_??1QSerialPortInfo@@QEAA@XZ),
error LNK2019: 无法解析的外部符号 "__declspec(dllimport) public: __thiscall QSerialPortInfo::QSerialPortInfo(class QSerialPortInfo const &)" (__imp_??0QSerialPortInfo@@QAE@ABV0@@Z),
以 QSerialport 为例
先包含头文件
#include <QtSerialPort/QSerialPort>
#include <QtSerialPort/QSerialPortInfo>
方法1
(其中Qt5SerialPort.lib是32位系统的配置文件,Qt5SerialPortd.lib是64位系统的配置文件。)
方法2
从下图可以知道,需要添加 serialport 模块
如果VS中按安装了 Qt VS Tools, 则在属性页中添加用到的模块即可