+ Reply to Thread
Results 1 to 4 of 4

Thread: LIBCMTD.lib and MSVCRTD.lib question

  1. #1
    Join Date
    Oct 2016
    Posts
    61
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default LIBCMTD.lib and MSVCRTD.lib question

    Hello sometimes when i add to my project my static compiler and dynamic compiler show me error's with LIBCMTD.lib and MSVCRTD.lib. Normally this can be solved including in the project the corresponding version you want to use for example i want to use static link libraries so when i create with only this. But sometimes when i select both in the project and select which i want to use show me these error's. Some way to obligate to my project to compile only in static or only dynamic using -MTd for static and -MD for Dynamic?
    How will be something like:
    CMAKE_XFLAGS_ ... I dont remember well how will be ? Thanks in advance!

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    3,008
    Thanks
    188
    Thanked 474 Times in 465 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: LIBCMTD.lib and MSVCRTD.lib question

    I use -MD (Release mode) and -MDd (Debug mode). In Debug mode, I also set the Project -> Properties -> Linker -> Input -> Ignore Specific Default Libraries property to "MSVCRT;%(IgnoreSpecificDefaultLibraries)"

    This eliminates the linking errors in Debug mode. For some strange reason this setting is not needed in Release mode. I don't have any idea how to do this in CMake. The linker command line in MSVC shows /NODEFAULTLIB:"MSVCRT", so maybe adding "-NODEFAULTLIB:'MSVCRT'" to your CMAKE_CXX_FLAGS variable will do this.

    You most likely cannot do static linking to the MSVC runtime libraries if you are using Qt DLLs. These will also be linked to the MSVC runtime DLLs, and you can't mix dynamic and static links to MSVC runtime libraries in the same executable.
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  3. #3
    Join Date
    Oct 2016
    Posts
    61
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: LIBCMTD.lib and MSVCRTD.lib question

    But the dynamic flags are (/MD and /MDd) and static flags are (/MT and /MTd).
    MD -> Multi Threaded DLL.
    MDd -> Multi Threaded Debug DLL . Like you said:
    -MD (Release mode) and -MDd (Debug mode).
    But normally it's for dynamic linking.

    And for static linking is -MT or -MTd.
    -MT -> Multi-Threaded
    -MTd -> Multi-Threaded Debug . In other words, -MT (Release mode) and -MTd (Debug mode).

  4. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    3,008
    Thanks
    188
    Thanked 474 Times in 465 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: LIBCMTD.lib and MSVCRTD.lib question

    And so? This is the part you need to read:

    You most likely cannot do static linking to the MSVC runtime libraries if you are using Qt DLLs. These will also be linked to the MSVC runtime DLLs, and you can't mix dynamic and static links to MSVC runtime libraries in the same executable.
    Meaning, you cannot link statically to the MSVC runtime (using -MT or -MTd) if you are linking to Qt DLLs (which use -MD or -MDd). If your code is completely self-contained (i.e. doesn't use Qt or any other DLLs linked to the MSVC runtime) then you can link however you want.
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

+ Reply to Thread

Similar Threads

  1. question about xmpp (different question)
    By davinciomar in forum Newbie
    Replies: 9
    Last Post: 6th September 2016, 13:52
  2. Question about ftp using Qt
    By lni in forum Qt Programming
    Replies: 11
    Last Post: 19th March 2014, 12:00
  3. Qwt question
    By baray98 in forum Qwt
    Replies: 3
    Last Post: 26th November 2007, 20:31
  4. A question
    By Michiel in forum QtCentre Programming Contest 2007
    Replies: 13
    Last Post: 12th March 2007, 08:44
  5. C++ question?
    By vermarajeev in forum General Programming
    Replies: 4
    Last Post: 25th October 2006, 13:30

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts