LNK2019 in Debug but not in Release

  • I installed the latest Qt SDK (Qt 5.0.2). I'm using Qt Creator 2.7 which uses msvc2012 64-bit.

    I created a project without UI-File. in MainWindow I only added my self-defined class derived by QWidget.

    I used a class (Painting) from a book which teaches Qt. I wanted to try out the paintEvent(QPaintEvent *event) function. When I run it in debug-mode, I get LNK2019 caused by Painting constructor in function MainWindow::MainWindow. I tried to run it in release-mode and the program executed normally without any errors.

    Can someone explain why a linker error occures in debug but not in release mode?

  • Moderators

    LNK2019 means the linker can't find a library.

    You'll need to provide more details about the error. Which library is it trying to find?

  • bq. mainwindow.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: __cdecl FormationWidget::FormationWidget(class QWidget *)" (??0FormationWidget@@QEAA@PEAVQWidget@@@Z)" in Funktion ""public: __cdecl MainWindow::MainWindow(class QWidget *)" (??0MainWindow@@QEAA@PEAVQWidget@@@Z)".

    it's german:
    "Verweis auf nicht aufgelöstes externes Symbol "
    "unresolved external symbol"

    "in Funktion"
    "in function"

    For more information here is my simple code:

    @FormationWidget::FormationWidget(QWidget *parent): QWidget(parent), x(0), y(0), lm(0)

    x, y and lm are of type "int"

    @MainWindow::MainWindow(QWidget *parent): QMainWindow(parent)
    fw = new FormationWidget(this);

    fw is of type "FormationWidget"

  • Moderators

    try to clean and rebuild your project.

  • I tried it many times, but still...

    I checked the whole folder where Qt 5.0.2 was installed, and there are debug files in both bin and lib (Qt5Guid.dll, Qt5Guid.lib).

  • Moderators

    Hmm... very strange. Can you post your .pro file?

    Also, open Qt Creator and go to Tools -> Options -> Build & Run -> Kits. What kits do you have? Do the settings look correct? Is there a yellow/red warning icon?

    Then, open your project, and click on "Projects" on the left (below "Debug", above "Help). Does the selected kit match your compiler?

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.