Compiler: Cygwin
OS : Windows 7 (64 bit)
C-Skills: Basic Understanding
So... I'm trying to make my cygwin compiler work with the cURL library, but it isn't really working all that well...
I've tried to completely re-install cygwin, by first removing the folder I stored cygwin in and then install cygwin with the 4 different cURL library's possible.
I can call functions from cURL in my terminal, and they work fine. But I'm trying to make one of the examples they got run.
Expand|Select|Wrap|Line Numbers
- #include <stdio.h>
- #include <stdlib.h>
- #include <unistd.h>
- #include <curl/curl.h>
- #include <curl/types.h>
- #include <curl/easy.h>
- static size_t write_data(void *ptr, size_t size, size_t nmemb, void *stream)
- {
- int written = fwrite(ptr, size, nmemb, (FILE *)stream);
- return written;
- }
- int main(int argc, char **argv)
- {
- CURL *curl_handle;
- static const char *headerfilename = "head.out";
- FILE *headerfile;
- static const char *bodyfilename = "body.out";
- FILE *bodyfile;
- curl_global_init(CURL_GLOBAL_ALL);
- /* init the curl session */
- curl_handle = curl_easy_init();
- /* set URL to get */
- curl_easy_setopt(curl_handle, CURLOPT_URL, "http://example.com");
- /* no progress meter please */
- curl_easy_setopt(curl_handle, CURLOPT_NOPROGRESS, 1L);
- /* send all data to this function */
- curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, write_data);
- /* open the files */
- headerfile = fopen(headerfilename,"w");
- if (headerfile == NULL) {
- curl_easy_cleanup(curl_handle);
- return -1;
- }
- bodyfile = fopen(bodyfilename,"w");
- if (bodyfile == NULL) {
- curl_easy_cleanup(curl_handle);
- return -1;
- }
- /* we want the headers to this file handle */
- curl_easy_setopt(curl_handle, CURLOPT_WRITEHEADER, headerfile);
- /*
- * Notice here that if you want the actual data sent anywhere else but
- * stdout, you should consider using the CURLOPT_WRITEDATA option. */
- /* get it! */
- curl_easy_perform(curl_handle);
- /* close the header file */
- fclose(headerfile);
- /* cleanup curl stuff */
- curl_easy_cleanup(curl_handle);
- return 0;
- }
$ gcc cURLtest.c
/tmp/ccsV6nAV.o:curltest.c:(.text+0x60): undefined reference to '_curl_global_init'
/tmp/cssV6nAV.o:curltest.c:(.text+0x65): undefined reference to '_curl_easy_init'
/tmp/cssV6nAV.o:curltest.c:(.text+0x83): undefined reference to '_curl_easy_setopt'
/tmp/cssV6nAV.o:curltest.c:(.text+0x9e): undefined reference to '_curl_easy_setopt'
....
And so on for every curl specific function.
collect2: id returned 1 exit status
Is it because these examples are too new? Maybe some of the functions isn't put into the Cygwin cURL lib?
And most of all, what do I do to solve this problem? I want to use cURL. In advance thanks for your help.