DELAYLOAD在Qt LNK2001中给出链接错误:未解析的外部符号

DELAYLOAD gives linking error in Qt LNK2001: unresolved external symbol

本文关键字:符号 外部 错误 链接 Qt LNK2001 DELAYLOAD      更新时间:2023-10-16

我正在尝试在Qt创建者中使用DELAYLOAD标志。以下是解释我的问题的最小代码:在pro文件中:

QT       += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = DelayLoad
TEMPLATE = app
CONFIG+=qwt
SOURCES += main.cpp
    mainwindow.cpp
HEADERS  += mainwindow.h
win32: LIBS += -L$$PWD/../../../../../qwt-6.1.2/lib/ -lqwt
INCLUDEPATH += $$PWD/../../../../../qwt-6.1.2/include
DEPENDPATH += $$PWD/../../../../../qwt-6.1.2/include
win32: QMAKE_LFLAGS_RELEASE += /DELAYLOAD:qwt.dll

mainwindow.cpp:中

#include "mainwindow.h"
#include <QPushButton>
#include "qwt_plot.h"
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
{
    QPushButton *button = new QPushButton("replace by plot");
    connect(button, SIGNAL(clicked(bool)),this,SLOT(buttonClicked()));
    this->setCentralWidget(button);
}
MainWindow::~MainWindow()
{
}
void MainWindow::buttonClicked()
{
    QwtPlot *plot = new QwtPlot();
    this->setCentralWidget(plot);
}

这会产生以下错误:

qwt.lib(qwt.dll):-1:错误:LNK2001:未解析的外部符号__delayLoadHelper2

我点击了几个Run qmakeClearRebuild。这并不能解决最初的问题。我将"Qt 5.4.2"与MSVC 2013 64 bit编译器一起使用

在.pro文件中添加以下行,没错。

win32:LIBS += "-LC:Program Files (x86)Microsoft Visual Studio 12.0VClibamd64" -ldelayimp
相关文章: