Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Windows: linking debug vs. release .libs, strange error!
QtWS25 Last Chance

Windows: linking debug vs. release .libs, strange error!

Scheduled Pinned Locked Moved Solved Qt Creator and other tools
9 Posts 2 Posters 1.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    davecotter
    wrote on last edited by
    #1

    I create a DLL, both debug and release versions, but they have the same name (CFLite.lib), in debug/rlease directories
    0_1535742526562_Screen Shot 2018-08-31 at 12.07.27 PM.png
    0_1535741881413_Screen Shot 2018-08-31 at 11.56.48 AM.png
    I then create a test app that links to it, both debug and release, which have different names ("CFTest" and "CFTest Debug")
    0_1535741923698_Screen Shot 2018-08-31 at 11.57.25 AM.png
    0_1535741937748_Screen Shot 2018-08-31 at 11.57.46 AM.png
    in my qmake file, i specify them to link to "CFLite", in debug/release directories, the name INSIDE the directory is the same (as mentioned above).

    REL_DIR_CFLITE = win-CFLite$${BUILD_TYPE_SUFFIX}/$${build_type}/
    message(CFLite Dir: $$REL_DIR_CFLITE)
    LIBS += -L$${DIR_OPENCFL}Qt/$${REL_DIR_CFLITE} -lCFLite
    

    the message produced for release is:

    Project MESSAGE: CFLite Dir: win-CFLite/release/
    

    for debug is:

    Project MESSAGE: CFLite Dir: win-CFLite Debug/debug/
    

    so we know that's all set up nicely.

    Linking the release app works. Attempting to link debug fails with this message:

    LINK : fatal error LNK1104: cannot open file 'CFLite_Debug.lib'
    

    But nowhere do i specify that the name of that lib ends with "_Debug"

    indeed, in the generated make file ".../qt/win-CFTest Debug/Makefile.Debug", it specifies the correct path and name:

    /LIBPATH:"..\..\..\..\CF\opencflite-476.17.2\Qt\win-CFLite Debug\debug" "..\..\..\..\CF\opencflite-476.17.2\Qt\win-CFLite Debug\debug\CFLite.lib"
    

    which you can see in the first screen shot is in fact the correct path.

    So WHY is the linker adding "_Debug" to the end of the file name for that lib? Where does it get that name?

    1 Reply Last reply
    0
    • D Offline
      D Offline
      davecotter
      wrote on last edited by davecotter
      #8

      My apologies. I found this in my code:

      #if OPT_WINOS
      	#ifdef kDEBUG
      		#define		kCFLiteLib	"CFLite_Debug"
      	#else
      		#define		kCFLiteLib	"CFLite"
      	#endif
      
      	#pragma comment(lib, kCFLiteLib ".lib")
      #endif
      

      which explains the whole problem, that was leftover from a different compiler, and i no longer need it!

      1 Reply Last reply
      2
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #2

        Hi,

        Can you show your complete .pro file ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • D Offline
          D Offline
          davecotter
          wrote on last edited by
          #3
          QT -= qtcore
          QT -= gui
          
          message(------------------------------)
          
          #for(var, $$list($$enumerate_vars())) {
          #    message($$var)
          #    message($$eval($$var))
          #	message(------)
          #}
          
          TEMPLATE = app
          
          DEFINES += QT_DEPRECATED_WARNINGS
          DEFINES += _QT_
          
          DEFINES += _CFTEST_
          DEFINES += _MIN_CF_
          DEFINES += _JUST_CFTEST_
          CONFIG += c++11
          
          macx {
          	DEFINES += OPT_MACOS=1
          
          	# on mac, you can ONLY build 64bit, there is no 32bit compiler
          	QMAKE_TARGET.arch = x86_64
          } else {
          	DEFINES += OPT_WINOS=1
          
          	# options: openssl | libressl
          	ssl_edition = libressl
          }
          
          contains(QMAKE_TARGET.arch, x86_64) {
          	DEFINES += __LP64__=1
          	build_depth = 64
          } else {
          	build_depth = 32
          }
          
          CONFIG(release, debug|release) {
          	build_type = release
          	build_Type = Release
          	BUILD_TYPE_SUFFIX = ""
          } else {
          	build_type = debug
          	build_Type = Debug
          	DEFINES += kDEBUG
          	BUILD_TYPE_SUFFIX = " Debug"
          }
          
          message(build_type: $${build_type})
          message($${TARGET} $${build_depth}bit)
          
          DIR_PROJ	= ../../
          DIR_CFTEST	= $${DIR_PROJ}../
          DIR_SOURCE	= $${DIR_CFTEST}source/
          DIR_CF		= $${DIR_CFTEST}../CF/
          
          macx {
          	QMAKE_LFLAGS += -F/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks
          	LIBS += -framework Carbon
          	LIBS += -framework CoreFoundation
          	LIBS += -framework ApplicationServices
          
          	QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7
          
          	QMAKE_CXXFLAGS_WARN_ON += -Wall -Wno-unused-parameter
          
          	SOURCES += \
          		$${DIR_CF}CFNetwork/NetServices/CFNetworkAddress.c
          
          	HEADERS += \
          		$${DIR_CF}CFNetwork/include/CFNetwork/CFNetworkAddress.h
          
          } else {
          	DEFINES += __WIN32__
          	DEFINES += _WINDOWS
          	DEFINES += WIN32
          	DEFINES += _WIN32
          	DEFINES += _UNICODE
          	DEFINES += UNICODE
          	DEFINES += _SCL_SECURE_NO_WARNINGS
          	DEFINES += _CRT_SECURE_NO_WARNINGS
          
          	# calling convention: __cdecl
          	QMAKE_CFLAGS += /Gd
          	QMAKE_CXXFLAGS += /Gd
          
          	DIR_OPENCFL = $${DIR_CF}opencflite-476.17.2/
          
          	CONFIG(release, debug|release) {
          		# mulithread dynamic link
          		QMAKE_CXXFLAGS += /MD
          		LIBS += -lmsvcrt
          	} else {
          		# mulithread dynamic link
          		QMAKE_CXXFLAGS += /MDd
          		DEFINES += _DEBUG
          		LIBS += -lmsvcrtd
          	}
          
          	REL_DIR_CFLITE = win-CFLite$${BUILD_TYPE_SUFFIX}/$${build_type}/
          	message(CFLite Dir: $$REL_DIR_CFLITE)
          	
          	LIBS += -L$${DIR_OPENCFL}Qt/$${REL_DIR_CFLITE} -lCFLite
          	LIBS += -lWs2_32 -lkernel32 -lole32 -loleaut32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -luuid -lodbc32 -lodbccp32
          	LIBS += -lcomctl32
          
          	INCLUDEPATH += $${DIR_OPENCFL}dist/include
          	DEPENDPATH	+= $${DIR_OPENCFL}dist/include
          	INCLUDEPATH += $${DIR_CF}CFNetwork/include
          }
          
          QMAKE_POST_LINK += python $${DIR_PROJ}post_build_cftest.py QT $$build_depth $$TARGET $$ssl_edition
          
          INCLUDEPATH += $${DIR_SOURCE}
          INCLUDEPATH += $${DIR_SOURCE}headers
          INCLUDEPATH += $${DIR_SOURCE}shared
          INCLUDEPATH += $${DIR_SOURCE}main
          INCLUDEPATH += $${DIR_CF}CFNetwork/include/CFNetwork
          
          SOURCES += \
          	$${DIR_SOURCE}shared/CCFData.cpp \
          	$${DIR_SOURCE}shared/CCFError.cpp \
          	$${DIR_SOURCE}shared/CFBonjour.cpp \
          	$${DIR_SOURCE}shared/CFUtils.cpp \
          	$${DIR_SOURCE}shared/CNetHTTP.cpp \
          	$${DIR_SOURCE}shared/SuperString.cpp \
          	$${DIR_SOURCE}main/CFNetworkTest.cpp \
          	$${DIR_SOURCE}main/CFTest.cpp \
          	$${DIR_SOURCE}main/CFTestUtils.cpp \
          	$${DIR_SOURCE}main/CWebServerTest.cpp \
          	$${DIR_SOURCE}main/main.cpp
          
          HEADERS += \
              $${DIR_SOURCE}shared/CCFData.h \
              $${DIR_SOURCE}shared/CCFError.h \
              $${DIR_SOURCE}shared/CFBonjour.h \
              $${DIR_SOURCE}shared/CFUtils.h \
              $${DIR_SOURCE}shared/CNetHTTP.h \
              $${DIR_SOURCE}shared/SuperString.h \
          	$${DIR_SOURCE}main/CFNetworkTest.h \
          	$${DIR_SOURCE}main/CFTest.h \
          	$${DIR_SOURCE}main/CFTestUtils.h \
          	$${DIR_SOURCE}main/CWebServerTest.h \
          	$${DIR_SOURCE}headers/stdafx.h
          
          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #4

            Looks fine...

            Do you have the same issue if you use qmake directly from the command line ?

            By the way, which version of Qt are you using ? With which version of Qt Creator ?

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • D Offline
              D Offline
              davecotter
              wrote on last edited by
              #5

              i don't know how to use it from command line.

              i'm on QtCreator 4.7.1, with Qt 5.11.1

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #6

                IIRC, when you installed Qt, you should have gotten an entry in your Start menu with a set of command prompt shortcuts. Are they there ?

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                0
                • D Offline
                  D Offline
                  davecotter
                  wrote on last edited by
                  #7

                  yes i have that, i click it and get this:

                  Setting up environment for Qt usage...
                  Remember to call vcvarsall.bat to complete environment setup!
                  
                  C:\Users\davec\Developer\Qt\5.11.1\msvc2017_64>
                  

                  Should i be worried about that "vcvarsall.bat" thing?

                  I'm assuming you're asking about the command line just as a test (to eliminate variables), and not as a solution. Sorry i don't know anything about doing it that way.

                  1 Reply Last reply
                  0
                  • D Offline
                    D Offline
                    davecotter
                    wrote on last edited by davecotter
                    #8

                    My apologies. I found this in my code:

                    #if OPT_WINOS
                    	#ifdef kDEBUG
                    		#define		kCFLiteLib	"CFLite_Debug"
                    	#else
                    		#define		kCFLiteLib	"CFLite"
                    	#endif
                    
                    	#pragma comment(lib, kCFLiteLib ".lib")
                    #endif
                    

                    which explains the whole problem, that was leftover from a different compiler, and i no longer need it!

                    1 Reply Last reply
                    2
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #9

                      Glad you found out and thanks for sharing !

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved