So I am trying to integrate the curl library into my c++ project. I did the following steps:
I thought this should be it to get CURL running, but I got a Linking error for every function call of the lib. EVEN after I added these libs to the additional dependencies setting in the linker input: Normaliz.lib;Ws2_32.lib;Wldap32.lib;Crypt32.lib;advapi32.lib;
Is there any solution available? In my searches on the internet I got always the solution, to include the Noraliz.lib;[...] and then it was told that it should run but it did not work for me. Would be happy about some help. Here is the code I tried to compile:
#include <iostream>
#define CURL_STATICLIB
#include <curl/curl.h>
#include <iostream>
static int writer(char* data, size_t size, size_t nmemb, std::string* writerData)
{
if (writerData == NULL)
return 0;
writerData->append(data, size * nmemb);
return size * nmemb;
}
int main(int argc, char** argv)
{
std::string content;
curl_global_init(CURL_GLOBAL_ALL);
CURL* curl = curl_easy_init();
if (curl)
{
curl_easy_setopt(curl, CURLOPT_URL, "");
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &content);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writer);
CURLcode code = curl_easy_perform(curl);
}
curl_easy_cleanup(curl);
curl_global_cleanup();
return 0;
}
you need add CURL_STATICLIB
macro defined in the "Preprocessor Definitions" section.
Maybe you can try teemo library, it based libcurl.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.