Qt w/ MSVC unable to use static linked curl
-
wrote on 22 Aug 2017, 11:35 last edited by
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
-
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
@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 ??
-
wrote on 22 Aug 2017, 20:37 last edited by jmarkson
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. -
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.
-
wrote on 22 Aug 2017, 21:03 last edited by
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?
-
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.
-
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.
-
Sure, just build curl statically but make it link to the dynamic runtime like Qt.
-
wrote on 23 Aug 2017, 03:08 last edited by
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 -
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.
1/10