Qt w/ MSVC unable to use static linked curl
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
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 ??
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
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.
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.
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.
@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
Sure, just build curl statically but make it link to the dynamic runtime like Qt.
To any future people with this question if you decide to build Qt for static linking this wiki page is very useful
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.