Important: Please read the Qt Code of Conduct -

How to prevent QtCreator from adding suffix "_d" to the libraries in the Debug mode?

  • Hello,

    My Qt project links with the library python27.lib on Windows 8.1. The .pro file contains the following line:

    win32:LIBS += C:\Python27_11\libs\python27.lib

    When building the project in Release mode, it links correctly with python27.lib.

    When building the project in Debug mode, it looks for python27_d.lib:

    Error: LNK1104: cannot open file 'python27_d.lib'

    How to enforce linking with python27.lib in the Debug mode?

    Thank you in advance!


  • Lifetime Qt Champion


    Looks pretty strange. AFAIK, Qt Creator doesn't do such thing (it just use qmake under the hood)

    What version of Qt and Qt Creator are you using ?

    On a side note, you should always use forward slashes when using Qt even on Windows. It will be handled properly for you.

  • Thank you for the response, SGaist. I agree that it might be qmake doing. However it's input must be based on parameters passed down to it by QtCreator when the Debug mode is selected.

    The version info:
    Qt Creator 3.5.1 (opensource)
    Based on Qt 5.5.1 (MSVC 2013, 32 bit)
    The OS is Windows 8.1 Pro 64 bit

    Please see the complete compile output below. Thank you!

    15:33:51: Running steps for project python...
    15:33:51: Starting: "C:\Qt\5.5\msvc2012\bin\qmake.exe" C:\Test\src\experimental\ -r -spec win32-msvc2012 "CONFIG+=debug"
    15:33:52: The process "C:\Qt\5.5\msvc2012\bin\qmake.exe" exited normally.
    15:33:52: Starting: "C:\Qt\Tools\QtCreator\bin\jom.exe" 
    	C:\Qt\Tools\QtCreator\bin\jom.exe -f Makefile.Debug
    	cl -c -nologo -Zc:wchar_t -Zi -MDd -GR -W3 -w34100 -w34189 -w44996 -EHsc /Fddebug\my_python.pdb -DUNICODE -DWIN32 -DQT_GUI_LIB -DQT_CORE_LIB -I..\experimental -I. -I..\..\..\..\Python27_11\include -I..\..\..\..\Qt\5.5\msvc2012\include -I..\..\..\..\Qt\5.5\msvc2012\include\QtGui -I..\..\..\..\Qt\5.5\msvc2012\include\QtANGLE -I..\..\..\..\Qt\5.5\msvc2012\include\QtCore -Idebug -I..\..\..\..\Qt\5.5\msvc2012\mkspecs\win32-msvc2012 -Fodebug\ @C:\Users\RONISI~1\AppData\Local\Temp\python.obj.4660.16.jom
    ..\experimental\ : warning C4100: 'argc' : unreferenced formal parameter
    	echo 1 /* CREATEPROCESS_MANIFEST_RESOURCE_ID */ 24 /* RT_MANIFEST */ "debug\\my_python.exe.embed.manifest">debug\my_python.exe_manifest.rc
    	if not exist debug\my_python.exe if exist debug\my_python.exe.embed.manifest del debug\my_python.exe.embed.manifest
    	if exist debug\my_python.exe.embed.manifest copy /Y debug\my_python.exe.embed.manifest debug\my_python.exe_manifest.bak
    	link /NOLOGO /DYNAMICBASE /NXCOMPAT /DEBUG /SUBSYSTEM:WINDOWS "/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='' publicKeyToken='6595b64144ccf1df' language='*' processorArchitecture='*'" /MANIFEST /MANIFESTFILE:debug\my_python.exe.embed.manifest /OUT:debug\my_python.exe @C:\Users\RONISI~1\AppData\Local\Temp\my_python.exe.4660.422.jom
    LINK : fatal error LNK1104: cannot open file 'python27_d.lib'
    jom: C:\Test\src\build-python-Desktop_Qt_5_5_1_MSVC2012_32bit-Debug\Makefile.Debug [debug\my_python.exe] Error 1104
    jom: C:\Test\src\build-python-Desktop_Qt_5_5_1_MSVC2012_32bit-Debug\Makefile [debug] Error 2
    15:33:52: The process "C:\Qt\Tools\QtCreator\bin\jom.exe" exited with code 2.
    Error while building/deploying project python (kit: Desktop Qt 5.5.1 MSVC2012 32bit)
    When executing step "Make"
    15:33:52: Elapsed time: 00:01.

  • Moderators

    @roni219 said:

    win32:LIBS += C:\Python27_11\libs\python27.lib

    When I link on windows I always use the *nix syntax and it has never given me any problems. Although it's a long-shot, perhaps you can try that?

    win32:LIBS += -LC:/Python27_11/libs -lpython27

  • Thank you for the suggestion, kshegunov. Yes, I tried the syntax earlier, and the result was the same.

  • Moderators

    This is certainly strange. Currently nothing comes to mind.
    As a sort of side note, are you using shadow building? Perhaps that is (or rather not using it is) causing the _d suffix being added ...

  • No, I do not use the shadow building.

    Based on my online research other people also experienced the issue. Unfortunately non of their posts on various forums was followed up with a solution.

  • Solved - the problem is with Python.h, not with QtCreator or qmake.

  • Lifetime Qt Champion

    Ok, that strangeā€¦

    Thanks for sharing !

Log in to reply