-
July 2nd, 2010, 09:25 AM
#1
libcURL init access violation
Using libcURL for a simple data retrieval program
when I call the init function:
curl_global_init(CURL_GLOBAL_ALL);
an access violation occurs
I also tried using the parameter CURL_GLOBAL_DEFAULT instead (out of curiosity) and it didn't help
I'm linking against the dll/lib and I also have copies of the dlls in my project directory
can anybody help me figure out how to get this fixed?
thanks
-
July 2nd, 2010, 09:31 AM
#2
Re: libcURL init access violation
Where? Does the access violation happen because you called curl_global_init, or within the function itself? curl_global_init doesn't really do a whole lot, so my guess is that the function isn't loading correctly from the dll.
Also, what are you doing with libcurl, most things can be done with the curl_easy... methods, which don't require you call curl_global_init. Unless you're doing in-depth SSL or something, you probably don't need it.
-
July 2nd, 2010, 09:43 AM
#3
Re: libcURL init access violation
it happens when I call it
I wish there was an easy way to tell if I finally got the lib/dll added correctly
I'm just trying to do a simple http request
(I would call it from winsock but servers won't talk to me when I use winsock :-/ )
-
July 2nd, 2010, 10:12 AM
#4
Re: libcURL init access violation
Forget winsock, use the libcurl built-in functions.
Now I'm writing this in the forum, so I haven't tested but
Code:
string getPage(const string & url){
string buffer;
if (CURL * curl = curl_easy_init()){
CURLcode res;
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writer);
curl_easy_setopt(easyhandle, CURLOPT_WRITEDATA, &buffer);
curl_easy_perform(curl);
curl_easy_cleanup(curl);
}
return buffer;
}
int writer(void * data, int size, int count, void * buffer){
char * newdata = memcpy((char*)malloc(size * count + 1), size* count, buffer);
newdata[size * count] = '\0';
((string *)buffer) -> append(newdata);
free(newdata);
return size * count;
}
-
July 2nd, 2010, 12:30 PM
#5
Re: libcURL init access violation
<s>[s]now curl_easy_init() crashes instead
it must be my dlls :-([/s]</s>
edit:
thanks for the excellent code
I decided to try it in the almighty dev-cpp instead and it works perfectly
There's something incompetent happening behind the scenes with VS that's making it not take the libs and relate to the need for its dlls properly
I guess this section isn't exactly a compiler support forum but I will need it to work in VS eventually
Any thoughts on what may be wrong?
Last edited by invaderjolleyolleyman; July 2nd, 2010 at 01:34 PM.
Reason: update
-
July 2nd, 2010, 01:51 PM
#6
Re: libcURL init access violation
I'll be I know exactly what is wrong. curl.dll almost certainly was compiled using MinGW, and MinGW mangles names differently than VC++, so VC++ programs can't find the functions that you are looking for. A library compiled for MinGW can not be used in VC++, and vise versa.
FYI, Dev-C++ is deprecated, it has been merged with Code::Blocks, so I recommend using that instead.
-
July 2nd, 2010, 03:50 PM
#7
Re: libcURL init access violation
thx for the info
that helps a lot
-and extra thanks for telling me about Code::Blocks
I knew Dev-cpp was discontinued and still had some issues but didn't know there was a new one
I'll look into it
-
July 2nd, 2010, 05:44 PM
#8
Re: libcURL init access violation
Originally Posted by invaderjolleyolleyman
<s>[s]now curl_easy_init() crashes instead
it must be my dlls :-([/s]</s>
edit:
thanks for the excellent code
I decided to try it in the almighty dev-cpp instead and it works perfectly
Please note that Dev-CPP is not a compiler. The actual compiler is g++, and Dev-CPP last worked with a a very old version of g++.
Regards,
Paul McKenzie
-
July 3rd, 2010, 06:49 AM
#9
Re: libcURL init access violation
yes, I'm well aware of that
I've used the same 'compiler' on other systems before
Most people use comfortable terms like compiler rather loosely however
such as calling visual studio a compiler when in fact there are only a few files in it's bin directory which are actually related to compilation
perhaps if I had called it an IDE you'd have felt more comfortable? XD
I'm in the process of trying to put libcurl in a new DLL for VS but don't expect to have much luck
If anyone has any tips on that, they'd also be appreciated
thx and sorry if I'm getting to far off-topic
-
July 4th, 2010, 10:37 PM
#10
Re: libcURL init access violation
Originally Posted by invaderjolleyolleyman
I'm in the process of trying to put libcurl in a new DLL for VS but don't expect to have much luck
If anyone has any tips on that, they'd also be appreciated
thx and sorry if I'm getting to far off-topic
Did you try this:
http://curl.haxx.se/dlwiz/?type=deve...in32&flav=MSVC
Regards,
Paul McKenzie
-
July 5th, 2010, 10:12 AM
#11
Re: libcURL init access violation
no, I didn't see that one
It's a bit hard to navigate their directories
I did manage to solve the problem though
I ended up downloading the src and recompiling the lib :-)
thx for all the help
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|