Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. Qt w/ MSVC unable to use static linked curl
Forum Updated to NodeBB v4.3 + New Features

Qt w/ MSVC unable to use static linked curl

Scheduled Pinned Locked Moved Solved Installation and Deployment
10 Posts 3 Posters 3.0k Views 2 Watching
  • 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.
  • J Offline
    J Offline
    jmarkson
    wrote on last edited by
    #1

    I am attempting to use curl with a Qt UI, but I run into one issue. If I try to change runtime library in code generation from Multi-threaded DLL (MD/MDd) I get

    Severity	Code	Description	Project	File	Line	Suppression State
    Error	LNK2038	mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MT_StaticRelease' in application.obj	curlupload	C:\Users\Justin\documents\visual studio 2017\Projects\curlupload\curlupload\qtmain.lib(qtmain_win.obj)	1	
    
    

    But I also still get unresolved externals from curl. Is there a way I can change Qt so I can statically use libcurl or is there another solution?

    TL;DR: How can I use curl with Qt on MSVC2017

    raven-worxR 1 Reply Last reply
    0
    • J jmarkson

      I am attempting to use curl with a Qt UI, but I run into one issue. If I try to change runtime library in code generation from Multi-threaded DLL (MD/MDd) I get

      Severity	Code	Description	Project	File	Line	Suppression State
      Error	LNK2038	mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MT_StaticRelease' in application.obj	curlupload	C:\Users\Justin\documents\visual studio 2017\Projects\curlupload\curlupload\qtmain.lib(qtmain_win.obj)	1	
      
      

      But I also still get unresolved externals from curl. Is there a way I can change Qt so I can statically use libcurl or is there another solution?

      TL;DR: How can I use curl with Qt on MSVC2017

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      @jmarkson said in Qt w/ MSVC unable to use static linked curl:

      If I try to change runtime library in code generation from Multi-threaded DLL (MD/MDd) I get

      something doesn't match here. You are trying to use curl lib statically, but already say yourself that you build a DLL ??

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      1
      • J Offline
        J Offline
        jmarkson
        wrote on last edited by jmarkson
        #3

        I am using libcurl which is built as a lib with /MT and CURL_STATICLIB in preprocessor then I put that in my project folder and #pragma comment (lib, "libcurl.lib"), but then I receive unresolved externals so I switch to compile as Multi-Threaded and Qt has a fit. When I use a project that doesn't use Qt these same steps work fine with my libcurl
        //edit
        Qt projects in MSVC are by default compiled as MD when you try to change it to MT you get the error I posted above.

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

          Hi,

          You can't just switch between MT and MD as you see fit. You have to build all your dependencies with the same runtime target.

          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
          • J Offline
            J Offline
            jmarkson
            wrote on last edited by
            #5

            I read about this, but I don't see anywhere in Qt to get the source to recompile as MT and as well another Moderator warned of instability and that it might not work. Do you mind pointing me to the direction of the download and whether or not the instability part is true?

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

              You can grab Qt's sources through the installer itself, the Qt project download page or using git.

              I can't comment on the stability of using the static runtime. What you really lose is any and all security, speed and stability improvements that might come with an update of the VS runtime.

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

              J 1 Reply Last reply
              0
              • SGaistS SGaist

                You can grab Qt's sources through the installer itself, the Qt project download page or using git.

                I can't comment on the stability of using the static runtime. What you really lose is any and all security, speed and stability improvements that might come with an update of the VS runtime.

                J Offline
                J Offline
                jmarkson
                wrote on last edited by
                #7

                @SGaist Is it there any way to link curl statically and others dynamically? I would look into linking curl dynamically, but I'd rather not have my program have to lug a curl dll where ever it goes

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

                  Sure, just build curl statically but make it link to the dynamic runtime like Qt.

                  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
                  • J Offline
                    J Offline
                    jmarkson
                    wrote on last edited by
                    #9

                    To any future people with this question if you decide to build Qt for static linking this wiki page is very useful
                    https://wiki.qt.io/Build_Standalone_Qt_Application_for_Windows

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

                      There's no need to build Qt statically in your case, just build libcurl statically with dynamic runtime. Also don't forget that building Qt statically has licensing consequences.

                      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