[Visual Studio] Error LNK2019, use C++ language, cooperate with Qt to develop serial communication interface

Knowledge is not alone, it must be systematic. More my personal summary and related experience can be found in this column: Visual Studio .

I encountered this bug when I was working on this project: [Visual Studio] Developed a serial communication interface with C++ language and Qt .

Article directory

question

When using C++ language and cooperating with Qt to develop the serial communication interface, the error code LNK2019 is reported.

Copy the error message so that others can retrieve my article when searching. The error message is as follows:

Severity Code Description Project File Line Suppressed Display Status
Error LNK2019 ??? "__declspec(dllimport) public: __cdecl QSerialPort::QSerialPort(class QObject *)" (_ imp ??0QSerialPort@@QEAA@PEAVQObject@@@Z), ?? “public: __cdecl GUI::GUI(class QWidget *)” (??0GUI@@QEAA@PEAVQWidget@@@Z) ??? GUI C:\Users\jicha\source\repos\GUI\GUI.obj 1

The screenshot of the error is as follows:

insert image description here

solution

A picture is better than the preface, and the solution should follow the picture below.

insert image description here

insert image description here

insert image description here

Note, don't forget to select other Modules required by the project. If you encounter similar problems in the future, you can solve them in the same way.

Finally, put another screenshot of the successful solution, hoping to help you.

insert image description here

Ref.

  1. 1. Unresolved external symbol "__declspec(dllimport) const XXX::vftable"` 2. `Cannot define dllimport entity`
  2. VS2017 uses QSerialPort to report LNK2019 error

Guess you like

Origin blog.csdn.net/weixin_36815313/article/details/131316671