开发者

Visual Studio compiled Qt Plugin doesn't load in release mode

I am developing a Qt application and a Qt Plugin library. Everything is working fine as far as I use the debug mode.

Nevertheless, when I try to compile in release mode the plugin doesn't load. I got the following error message from QPluginLoader:

Expected build key "Windows msvc release full-config" got "Windows msvc debug full-config".

I have checked all my project configuration settings in Visual Studio 2005, and they are all in release mode and without debug symbols. Also the output of the compiler states that:

1>------ Rebuild All started: Project: ExtraAnalysisTools, Configuration: Release Win32 ------ 1>Deleting intermediate and output files for project 'ExtraAnalysisTools', configuration 'Release|Win32'

So I don't know what more to开发者_JAVA技巧 do. I tried to use Dependency Walker, but for some reason it cannot load the file (sorry the output is in Japanese...)

Finally, here is the .pro file I use to generate the plugin project

TEMPLATE = lib

CONFIG += plugin

CONFIG += debug_and_release

INCLUDEPATH += ../

HEADERS = ExtraAnalysisTools.h

SOURCES = ExtraAnalysisTools.cpp

TARGET = AKL_ExtraAnalysisTools

DESTDIR = ./

build_pass:CONFIG(debug, debug|release) {

unix: TARGET = $$join(TARGET,,,_debug)

else: TARGET = $$join(TARGET,,,d)

}

CONFIG(debug,debug|release):message("Debug mode")

CONFIG(release,debug|release):message("Release mode")

message( CONFIG = $$CONFIG )

Update: I use now this .pro file and get the following output:

[1] - Project MESSAGE: Debug mode

[2] - Project MESSAGE: CONFIG = lex yacc warn_on debug uic resources rtti_off exceptions_off stl_off incremental_off thread_off windows qt warn_on release incremental flat link_prl precompile_header autogen_precompile_source copy_dir_files debug_and_release debug_and_release_target embed_manifest_dll embed_manifest_exe debug shared stl exceptions rtti mmx 3dnow sse sse2 def_files plugin debug_and_release

[3] - Project MESSAGE: Debug mode

[4] - Project MESSAGE: CONFIG = lex yacc warn_on debug uic resources rtti_off exceptions_off stl_off incremental_off thread_off windows debug DebugBuild Debug build_pass qt warn_on release incremental flat link_prl precompile_header autogen_precompile_source copy_dir_files debug_and_release debug_and_release_target embed_manifest_dll embed_manifest_exe debug shared stl exceptions rtti mmx 3dnow sse sse2 def_files debug DebugBuild Debug build_pass plugin debug_and_release

[5] - Project MESSAGE: Release mode

[6] - Project MESSAGE: CONFIG = lex yacc warn_on debug uic resources rtti_off exceptions_off stl_off incremental_off thread_off windows release ReleaseBuild Release build_pass qt warn_on release incremental flat link_prl precompile_header autogen_precompile_source copy_dir_files debug_and_release debug_and_release_target embed_manifest_dll embed_manifest_exe debug shared stl exceptions rtti mmx 3dnow sse sse2 def_files release ReleaseBuild Release build_pass plugin debug_and_release

I noticed the debug flags in the released mode, so I also tried to add the CONFIG -= debug and CONFIG -= Debug debug to my .pro file (also combining with += release and += debug_and_release). But it didn't work.

I hope with this extra information we can get closer to the problem.

Thank you very much! It's driving me crazy xP


You'll get this error if you compile your plugin's with the debug libraries and your EXE with the release libraries. The solution is to make sure your executable and dll's are compiled with the same configuration (release or debug).

In visual studio, under the project settings, you can check Linker ->Input and make sure the libraries listed there are missing the "d" suffix (QtCored4.dll is debug, QtCore4.dll is release).

The .pro files in Creator are a little trickier, since debug is always defined (release "overrides" debug). there warnings all over the Qt make documentation about using debug_and_release. I would recommend just compiling one or the other at a time - the extra trouble of that flag just isn't worth it, imo.


I gues you are lacking of QT_NO_DEBUG preprocessor flag in you release configuration. That's why your "release" build gets plugin build key with "debug" mode. And your workaround is realy "nasty", because registry entries for plugins are recreated after each plugin modification


Add the following lines to your .pro file and see what it will print. The explicit CONFIG += release is kinda fishy. Remember that if debug is already in CONFIG, it overrides release.

CONFIG(debug,debug|release):message("Debug mode")
CONFIG(release,debug|release):message("Release mode")

If it prints both entries, there might already be a CONFIG += debug elsewhere.


Well, actually it was a problem only related to Visual Studio configuration. I was rearranging my project setup to include a new shared library and suddenly it worked...

Although I was compiling different versions of the plugin using debug and release, because of the qmake project file I used to import the correct Qt flags into the project, the destination folder was common to both versions probably mixing some intermediate file (dll files were different).

I am not sure 100% if this was the real cause, but if you face another problem similar to this one, try first using different destination directories.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜