views:

53

answers:

4

Hi,

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 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

A: 

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.

andref
Thank you for your tip. It prints Release mode. I also recompiled my qt libs with debug-and-release configure flag (although I think they were already compiled with that flag). But it doesn't work.The only work around I've found is editing the win register to modify the plugin dll entrance string replacing debug with release. After modifying this entrance I can load the libraries in release mode. So I guess the Qt libraries are right, and the only thing I need to do is find who is the responsible of this setting.
lokifacio
Can you try compiling on Qt Creator just to check if the generated dlls are loaded?
andref
A: 

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

Kamil Klimek
Mmmmm no.My preprocesor flags for the plugin are:QT_NO_DEBUG, NDEBUG, UNICODE, WIN32, QT_LARGEFILE_SUPPORT, QT_DLL, QT_PLUGIN, QT_GUI_LIB, QT_CORE_LIB, QT_THREAD_SUPPORTAnd for the application:UNICODE, WIN32, QT_LARGEFILE_SUPPORT, QT_THREAD_SUPPORT, QT_NO_DEBUG, NDEBUG, QT_CORE_LIB, QT_GUI_LIBAbout the workaround, I know. I don't use it in production, only used to see if I could get some extra clue.
lokifacio
A: 

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.

lokifacio
A: 

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.

danielweberdlc