0x26res
0x26res

Reputation: 13892

Using libcurl on windows, in my c++ project, with visual studio, does not work because string get corrupted

As explained in the title, I am trying to use the libcurl C API to submit simple http query.

I am using windows as an OS, C++ as a language, Visual Studio 2008 as an IDE.

My code is quiet simple:

I initialize curl: CURLcode init = curl_global_init(CURL_GLOBAL_ALL);

I initialize my handle: CURL* handle = curl_easy_init();

I set the url: CRULcode set_url = curl_easy_setopt(handle, CURLOPT_URL, "http://www.example.com")

I submit my request: CURLcode submit = curl_easy_perform(handle);

As a result, the init and set_url return codes are 0 (CURLE_OK), the subimt return code is 2 (CURLE_URL_MALFORMAT).

When I debug I realize that my URL got corrupted, and instead of being http://www.example.com it becomes: xj: in release mode and 0|: in debug mode. It happens as soon as I enter curl_easy_setopt

The URL string gets definitely corrupted.

There must be one of my settings that is wrong, so here is a summary of my settings (in debug mode)

Upvotes: 0

Views: 3715

Answers (1)

9dan
9dan

Reputation: 4272

"Linking againgst libcurld.lib (version 7.21.3) compile using the vc6curl.dsw project"

This is the problem.

Static libraries must be built with the same compiler and the same runtime libraries (/MDd).

You can avoid this with DLL version of libcurl.

Upvotes: 3

Related Questions