简体   繁体   English

Qt应用程序无法加载自定义插件调试库

[英]Qt application fails to load custom plugin debug library

My question: 我的问题:
Why does my test application, when running in Release, not load the Debug (-d) version of my plugin DLL and instead only load the Release version? 为什么我的测试应用程序在Release中运行时,为什么不加载插件DLL的Debug(-d)版本,而仅加载Release版本?

The background: 的背景:
I'm building a custom Qt Designer plugin, QDragableToolBox; 我正在构建一个自定义的Qt Designer插件QDragableToolBox; I am testing it with a very simple Qt application. 我正在用一个非常简单的Qt应用程序对其进行测试。 I link to my plugin library as shown in the .pro code below. 我链接到我的插件库,如下面的.pro代码所示。

My plugin works fine in Release mode. 我的插件在发布模式下可以正常工作。 When I attempt to run in Debug, the test application fails to get past the constructor of the plugin and simply ends without warning or error. 当我尝试在Debug中运行时,测试应用程序无法通过插件的构造函数,而只是结束而没有警告或错误。 I have seen this before with Debug/Release library conflicts and therefore used Dependency Walker to check which library the executable is searching for. 我之前在Debug / Release库冲突中已经看到了这一点,因此使用Dependency Walker来检查可执行文件正在搜索哪个库。 Sure enough, it is looking for the Release library, not the Debug library as appended with 'd'. 果然,它正在寻找Release库,而不是在d之后附加的Debug库。

I have further confirmed that this is the case by removing the 'd' from the filename of the Debug DLL. 我已经通过从调试DLL的文件名中删除“ d”来进一步确认这种情况。 When that is done, the test application runs perfectly. 完成后,测试应用程序将完美运行。 I know that it is in fact loading the Debug library in this case as I have included a message box popup stating the library type (Debug vs. Release). 我知道在这种情况下实际上是在加载Debug库,因为我包括了一个提示框,说明了库的类型(Debug vs. Release)。

I can post the actual code if need be, but I don't think that it relates to the problem because Release works fine. 如果需要,我可以发布实际的代码,但是我认为这与问题无关,因为Release可以正常工作。

Thank you. 谢谢。

Here are my project files: 这是我的项目文件:

Plugin library .pro: 插件库.pro:

QT          += widgets designer

QMAKE_LFLAGS += /INCREMENTAL:NO

TARGET      = $$qtLibraryTarget($$TARGET)
TEMPLATE    = lib

CONFIG     += plugin
CONFIG     += debug_and_release

target.path = $$[QT_INSTALL_PLUGINS]/designer
INSTALLS += target

HEADERS     = qdragabletoolbox.h \
              qdragabletoolboxplugin.h \
              qdragabletoolboxextensionfactory.h \
              qdragabletoolboxcontainerextension.h
SOURCES     = qdragabletoolbox.cpp \
              qdragabletoolboxplugin.cpp \
              qdragabletoolboxextensionfactory.cpp \
              qdragabletoolboxcontainerextension.cpp

RESOURCES += qdragabletoolbox.qrc

OTHER_FILES += qdragabletoolbox.json

Test executable .pro: 测试可执行文件.pro:

QT       += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

QMAKE_LFLAGS += /INCREMENTAL:NO

TARGET = QDesignerPluginTester
TEMPLATE = app

CONFIG += debug_and_release

LIBS += -LF:/Custom_Plugins/QDragableToolBox/output -lQDragableToolBox
LIBS += -LF:/Custom_Plugins/QMultiPageWidget/output -lQMultiPageWidget
LIBS += -LF:/Custom_Plugins/QLED/output -lQLED

SOURCES += main.cpp\
        testwidget.cpp

HEADERS  += testwidget.h

FORMS    += \
    testwidget.ui

该文档明确指出,必须使用与应用程序相同的设置来构建该插件: http : //qt-project.org/doc/qt-5/deployment-plugins.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM