cURL / Mailing Lists / curl-library / Single Mail


[C/C++] Problem to use curl with Visual 2010

From: guillaume opalach <>
Date: Tue, 11 Oct 2011 00:12:42 +0000


I have a bug when I try to execute this code :

#include <stdio.h>
#include <curl/curl.h>

int main(void)
  CURL *curl;
  CURLcode res;
  curl = curl_easy_init();
    curl_easy_setopt(curl, CURLOPT_URL, "");
    res = curl_easy_perform(curl); // error is here
    /* always cleanup */
  return 0;

The error message is the following :

Debug Assertion Failed !
File: f\dd\vctools\crt_bld\self_x86\crt\dbgheap.c
Line: 1322

Expression: _CrtIsValidHeapPointer(pUserData)

I'm using Visual C++ 2010 on Windows 7. and I have curl-7.22.0
I use my "own version" of the curl library, I follow a tutorial found somewhere on your website (I can't find the url again ><)
I've open vc6curl.dsw and I build the LIB-RELEASE and the DLL-RELEASE.
I copy the libcurl.dll and the libcurl.lib created into my project's directory.
After that, on Visual I've done the following action (my visual is in french so I'll try to translate)
1 --
- Right click on the project name
- Properties
- Configuration Properties
- C/C++ (General)
- Added the path to an include repertory with the curl header file.
2 --
- Right click on the project name

- Properties

- Configuration Properties

- C/C++
- Preprocessor
(without this define, I can't make the .exe)
3 --
- Right click on the project name

- Properties

- Configuration Properties
- Linker (General)
- In "repertory for additionnal library", I've add a path to the libcurl.lib
4 --
- Right click on the project name

- Properties

- Configuration Properties
- Linker
- Entry (? maybe this traduction is wrong, it's the second menu, just under General)
- Additionnal dependency -> I add libcurl.lib; ws2_32.lib; wldap32.lib

That's all. I don't know what to do with the libcurl.dll, I've put it in the same directory than libcurl.lib.
I can compile the project without any error, but when I run the executable, an error message (Debug insertion failed)
I tried to compile the project in Release and not Debug, but I get another error message.

So, when I execute this code in step by step, the error appear in this line :
 -- res = curl_easy_perform(curl);
I've get in the cURL code to see what where the error happen :

easy.c - function curl_easy_perform(CURL * curl) - Line 537 - return Curl_perform(data);

transfer.c - function Curl_perform(struct SessionHandle *data) - Line 2261 - return Curl_do_perform(data);

transfer.c - function Curl_do_perform(struct SessionHandle *data) - Line 2115 - res = connect_host(data, &conn);

transfer.c - static function connect_host(struct SessionHandle *data, struct connectdata **conn) - Line 1982 - res = Curl_resolver_wait_resolv(*conn, NULL);

asyn-thread.c - function Curl_resolver_wait_resolv(struct connectdata *conn, struct Curl_dns_entry **entry) - Line 509 - destroy_async_data(&conn->async);

asyn-thread.c - static function destroy_async_data (struct Curl_async *async) - Line 327 - free(async->hostname);

I don't get deeper, because it's the function free, it's a system function and not a curl function.
I really don't know why my code is not working but I think that, if the problem don't came from my code, there's only 3 option:
- A problem with the libcurl.lib (wrong compilation?)
- A problem with my Visual configuration (maybe I forget something?)
- A bug in the curl code o_O ?

I hope that someone can help me to solve this problem because I've really tried everything that I can.

Best regard,


List admin:
Received on 2011-10-11