Answer the question
In order to leave comments, you need to log in
Build an example C++11 CURL application in MVS2019?
I took an example from the site: https://curl.se/libcurl/c/https.html
#include <stdio.h>
#include <curl/curl.h>
int main(void)
{
CURL* curl;
CURLcode res;
curl_global_init(CURL_GLOBAL_DEFAULT);
curl = curl_easy_init();
if (curl) {
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
#ifdef SKIP_PEER_VERIFICATION
/*
* If you want to connect to a site who isn't using a certificate that is
* signed by one of the certs in the CA bundle you have, you can skip the
* verification of the server's certificate. This makes the connection
* A LOT LESS SECURE.
*
* If you have a CA cert for the server stored someplace else than in the
* default bundle, then the CURLOPT_CAPATH option might come handy for
* you.
*/
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
#endif
#ifdef SKIP_HOSTNAME_VERIFICATION
/*
* If the site you're connecting to uses a different host name that what
* they have mentioned in their server certificate's commonName (or
* subjectAltName) fields, libcurl will refuse to connect. You can skip
* this check, but this will make the connection less secure.
*/
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
#endif
/* Perform the request, res will get the return code */
res = curl_easy_perform(curl);
/* Check for errors */
if (res != CURLE_OK)
fprintf(stderr, "curl_easy_perform() failed: %s\n",
curl_easy_strerror(res));
/* always cleanup */
curl_easy_cleanup(curl);
}
curl_global_cleanup();
return 0;
}
Warning C26812 The enum type 'CURLcode' is unscoped. Prefer 'enum class' over 'enum' (Enum.3)
Error LNK2019 unresolved external symbol __imp__curl_global_init referenced in function _main
.... etc.
curl.7.30.0.2
curl.redist.7.30.0.2
libssh2.1.4.3.1
libssh2.redist.1.4.3.1
openssl.1.0.1.21
openssl.redist.1.0.1.21
zlib.1.2.8.1
zlib.redist.1.2.8.1
Answer the question
In order to leave comments, you need to log in
You have problems with linking, import libraries or static libraries are not configured or chosen incorrectly (depending on how you plan to link libcurl to your example project).
It is also possible that the compiler definitions are configured incorrectly - some libraries require preprocessor constants to be set for dynamic, or vice versa, static linking. For example, libcurl requires configuration CURL_STATICLIB
for static linking.
All packages installed from VS package manager
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question