PDA

View Full Version : Help with linking / debugger



simb22
12th June 2012, 03:32
I'm a total newbie with QT. I have a problem that's driving me NUTS.

I have a program that compiles fine in 'release' mode; however, when I change to 'debug' mode, I get the message: "File not found: msvcprtd.lib (MSVCP90D.dll)". I have included the line
LIBS += "C:/Program Files/Microsoft Visual Studio 9.0/VC/lib/msvcprtd.lib" in the .pro file (which contains the .lib file), but that isn't fixing the problem.

Any help will be appreciated.


Thanks

aamer4yu
12th June 2012, 08:19
Can you share the .pro file ? Have you included conditional LIBS+= based on release and debug ?
Check the include / lib paths for release and debuig modes

ChrisW67
12th June 2012, 08:48
That's a debug version of a Microsoft Visual C++ runtime library. The problem is that it's required and not present. It should be found installed as a SxS assembly and in a redist directory of Visual Studio 9.0 in any correctly configured, fairly recent Microsoft dev environment.

simb22
13th June 2012, 05:43
Thank you for your responses. Forgive my 'newbie-ness', but I thought that by including the line LIBS += "C:/Program Files/Microsoft Visual Studio 9.0/VC/lib/msvcprtd.lib" , the linker should have found it. The file is in that directory. As you suggested, aamer4yu, here is a cut-down version of the .pro file:




# ----------------------------
# Project created by QtCreator
# ----------------------------
# defines for shared settings
# if you change these be sure to adjust the libs below. Search for the constants.
DEFINES += SHARED_USE_MIDITALK
DEFINES += SHARED_USE_GENERALPLUSTALK
DEFINES += SHARED_USE_DOWNLOADMANAGER

# Download Manager needs this (SHARED_USE_DOWNLOADMANAGER)
QT += network
TARGET = xxxxx
TEMPLATE = app
SOURCES += main.cpp \
(other .cpp programs)
HEADERS += ../MyDir/BaseWindow.h \
(other .g files)

# now add the platform specific libs.
win32 {
# The below causes the manifest file to be external instead of inside the exe. This is done so we can set the Windows UAC (User Access Control)
CONFIG -= embed_manifest_exe

# common stuff
DEFINES += _CRT_SECURE_NO_WARNINGS


DEFINES += __WINDOWS_MM__
LIBS += Winmm.lib


INCLUDEPATH += ../MyDir/USBPlugin
DEFINES += WINDOWS_MM__
DEFINES += _MBCS
DEFINES -= UNICODE
DEFINES -= _UNICODE
LIBS += .(various .lib files)
LIBS += "C:/Program Files/Microsoft Visual Studio 9.0/VC/lib/msvcprtd.lib"
LIBS += /NODEFAULTLIB:msvcrt.lib
QMAKE_CFLAGS_RELEASE -= -MD
QMAKE_CFLAGS_RELEASE += -MT
QMAKE_CXXFLAGS_RELEASE -= -MD
QMAKE_CXXFLAGS_RELEASE += -MT

# Application Icon
RC_FILE = ../YRG-APP-Engine/YRGicon.rc
}
macx { (mac stuff )
}

# Finally add the resources.
RESOURCES += Resources.qrc

ChrisW67
13th June 2012, 08:58
Your original complaint was about debug builds, and nothing you done in this PRO specifically changes the default behaviour for a debug build... i.e. to use DLLs.

What makes you think you need to explicitly specify the static MS VC and C++ runtime libraries? A quick test here indicates that using "/MT" alone is sufficient to remove the dependency on the DLL and use the static libraries.

With this source file:


#include <iostream>

int main(int argc, char **argv) {
std::cout << "Hello world" << std::endl;
return 0;
}

and this command line in a VS command prompt:


cl /MDd main.cpp

do you get a working executable without complaints about missing libraries? How about with "/MTd" ?

simb22
13th June 2012, 16:11
Thanks, Chris. I'll test this when I get home tonight.

simb22
15th June 2012, 00:43
It was indeed a compiler (actually linker) problem. Thank you for your help