Re: Crash in the DLL
Date: Sun, 26 Aug 2001 18:28:18 +0200 (MET DST)
On Sun, 26 Aug 2001, Steve Lhomme wrote:
> I've build the DLL with Visual C++ 6, and with the simple FTP example, it
> crashes when writing into the file ! So I've tried to debug it, and it's
> on the data->fwrite. So I tried a static build and it worked !
> I really didn't understand what happened. I've tried calling the standard
> fwrite in the DLL and out of the DLL with exactly the same parameters
> (same string, length, stream). And it crashes in the DLL and not inside !
> (in the same program/run)
I think the answer can be found in the FAQ, item 5.5:
5.5 Does CURLOPT_FILE and CURLOPT_INFILE work on win32 ?
Yes, but you cannot open a FILE * and pass the pointer to a DLL and have
that DLL use the FILE *. If you set CURLOPT_FILE you must also use
CURLOPT_WRITEFUNCTION as well to set a function that writes the file, even
if that simply writes the data to the specified FILE*. Similarly, if you
use CURLOPT_INFILE you must also specify CURLOPT_READFUNCTION.
(Provided by Joel DeYoung and Bob Schader)
... and in fact in the man page for curl_easy_setopt() in the CURLOPT_FILE
there's also this text:
NOTE: If you're using libcurl as a win32 DLL, you MUST use the
CURLOPT_WRITEFUNCTION if you set this option.
Of course, I should correct that example so that it'll work on windows too
from the start.
-- Daniel Stenberg -- curl groks URLs -- http://curl.haxx.se/Received on 2001-08-26