Date: Mon, 10 Oct 2011 23:30:11 -0700 Subject: Re: [C/C++] Problem to use curl with Visual 2010 From: [email protected] To: [email protected] not sure if it will help, but your program and libcurl need to match for some compilation settings. #1 - you need to use the same CLR (runtime). If you use "multithreaded debug dll" in your program, but libcurl is compiled with "multithreaded debug" for instance, that will cause problems. #2 - make sure that your exceptions and rtti settings in your program match the settings you built libcurl with (although i think this will may cause linker errors if this is wrong) On Mon, Oct 10, 2011 at 5:12 PM, guillaume opalach <[email protected]> wrote: Hello, 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_global_init(CURL_GLOBAL_ALL); curl = curl_easy_init(); if(curl) { curl_easy_setopt(curl, CURLOPT_URL, "http://www.google.com/"); res = curl_easy_perform(curl); // error is here /* always cleanup */ curl_easy_cleanup(curl); } return 0; } ---------------------------------------------------- The error message is the following : ---------------------------------------------------- Debug Assertion Failed ! C:\...\testCurl.exe 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 - Add the BUILDING_LIBCURL and HTTP_ONLY define (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, -- Guillaume ------------------------------------------------------------------- List admin: http://cool.haxx.se/list/listinfo/curl-library Etiquette: http://curl.haxx.se/mail/etiquette.html ------------------------------------------------------------------- List admin: http://cool.haxx.se/list/listinfo/curl-library Etiquette: http://curl.haxx.se/mail/etiquette.html Hello again, First of all, I'm puting my text here because in the rules, you said to avoid top posting. I'm not an english native so I maybe misunderstand what it means and in that case, please excuse me. So, as you said in the #1, the "runtime library" (in Properties, C/C++, code generation) was not the same in the LIB-RELEASE and in my project. But, in the LIB-DEBUG, the runtime library was exacly the same that the one use in my project. I've compile the LIB-DEBUG (which, by the way don't give me a libcurl.lib but libcurld.lib ... I've lost half an hour because of this ><), I've rename it and IT WORKS !!! Thank you very much for your help I'll try to be aware of this error in the futur. Best regards, -- Guillaume
------------------------------------------------------------------- List admin: http://cool.haxx.se/list/listinfo/curl-library Etiquette: http://curl.haxx.se/mail/etiquette.html
