Configure CURL on Code::Blocks C++

Job ID: 39310959

Budget: ₹1,500 – ₹12,500 INR

Project is to configure curl and Code::Blocks to compile and run the following code, (Ubuntu 22.04).

Including the Build Options for me to reproduce in Build::Blocks.



#include <iostream>

#define CURL_STATICLIB

#include "curl/curl.h"

#include "curl/typecheck-gcc.h"

#include "curl/easy.h"

CURL *curl_easy_init();



static size_t

WriteCallback(

char *receivedData,

size_t dataSize,

size_t dataBlocks,

void *outputBuffer

) {

std::string *strBuffer = static_cast(outputBuffer);

strBuffer->append(receivedData, dataSize * dataBlocks);

return dataSize * dataBlocks;

}



int main() {

curl_global_init(CURL_GLOBAL_DEFAULT);

CURL *curl = curl_easy_init();

std::string readBuffer;



if (curl) {

curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");

curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);

curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer);

CURLcode res = curl_easy_perform(curl);



if (res != CURLE_OK)

std::cerr << "Error: " << curl_easy_strerror(res) << std::endl;



curl_easy_cleanup(curl);

}



curl_global_cleanup();

std::cout << "Data: " << readBuffer << std::endl;

return 0;

}



The example project: https://github.com/voidlib/cpp-curl-example/blob/main/1_simplest_http_get.cpp



The delivery is the app, and intructions how to make the cofiguration.
Related categories: C Programming Python Linux C++ Programming cURL