How do I build a debug mode QT app that links to a lib built in release mode?
I have a QT install that I rebuilt with VC2008 on Windows XP, SP3. I am building a debug mode version of a basic QT app.
I am linking to a library that was built in release mode. Both are using the DLL version of MSVCRT, except the lib I'm linking to is obviously linked to the non debug version.
When I run the app, even with only one line of code that has a stack allocated object from the linked in lib, I get a crash due to some kind of memory allocation. When I comment out that one line that stack allocs that foreign lib's object the crash goes away.
Or if I build the QT app in release mode, the crash goes away, but then I can't debug the QT app.
Thanks for any help, I'm tearing my hair out over this.
Btw, when I build the app, I do get this warning:
LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
I've tried using the /NODEFAULTLIB:<nameoflib> in the command line options of the linker settings in VC2008, but the message doesn't go away and it solves nothing.
Re: How do I build a debug mode QT app that links to a lib built in release mode?
Try using Qt debug libraries built against the non-debug msvcrt. You won't be able to debug into the crt code, obviously, but it should let you debug into the Qt libraries at least.
Cheers,
-andy.f
Re: How do I build a debug mode QT app that links to a lib built in release mode?
Quote:
Originally Posted by
andy.fillebrown
Try using Qt debug libraries built against the non-debug msvcrt. You won't be able to debug into the crt code, obviously, but it should let you debug into the Qt libraries at least.
Cheers,
-andy.f
Does that mean I have to rebuild QT so that it links against the non-debug MSVCRT? If so, how do I instruct the configure.exe so that it does this?
Re: How do I build a debug mode QT app that links to a lib built in release mode?
you can built Qt with -debug-and-release configure key, that allows to use Qt in debug and release modes by adding CONFIG += release/debug flag in pro-file of your application.
so, you need:
Quote:
configure.exe -debug-and-release
mingw32-make (or nmake for MS VC)
Re: How do I build a debug mode QT app that links to a lib built in release mode?
Quote:
Originally Posted by
spirit
you can built Qt with
-debug-and-release configure key, that allows to use Qt in debug and release modes by adding
CONFIG += release/debug flag in pro-file of your application.
so, you need:
Code:
configure.exe -debug-and-release
mingw32-make (or nmake for MS VC)
Thanks, I'll give that a try. Is there a way to do a clean before re-making or re-configing?
Re: How do I build a debug mode QT app that links to a lib built in release mode?
yup
Quote:
mingw32-make clean (or for MS VS: nmake clean)
but you should run this command in QTDIR.
Re: How do I build a debug mode QT app that links to a lib built in release mode?
Quote:
Originally Posted by
spirit
yup
but you should run this command in QTDIR.
Thanks, QTDIR meaning c:\qt\2009.1\qt in my case?
or the root, being c:\qt\2009.1 ?
Re: How do I build a debug mode QT app that links to a lib built in release mode?
Quote:
Originally Posted by
Joachie
QTDIR meaning c:\qt\2009.1\qt in my case?
yes, c:\qt\2009.1\qt.
Re: How do I build a debug mode QT app that links to a lib built in release mode?
Quote:
Originally Posted by
spirit
you can built Qt with -debug-and-release configure key, that allows to use Qt in debug and release modes by adding CONFIG += release/debug flag in pro-file of your application.
so, you need:
Ok, I rebuilt as you suggested. So should all the libs now be using the non debug version of MSVCRT? Because the debug QT libs still appear to be using the debug version of MSVCRT.
Re: How do I build a debug mode QT app that links to a lib built in release mode?
how do you know? did you use Dependency walker? use it on Qt libs which ending without "d".