cURL / Mailing Lists / curl-library / Single Mail

curl-library

cannot link to libcurl under cygwin

From: Chris Scaffidi <chris.scaffidi_at_gmail.com>
Date: Mon, 23 May 2005 13:59:26 -0400

I have had no success linking libcurl to a simple test application. The
linker keeps telling me that it cannot resolve references.
 I am using the -l and -L options. Perhaps I am not using them properly?
 Any help that you can provide would be deeply appreciated.
 Thanks,
Chris
  Steps to reproduce:
 - Downloaded Cygwin and installed at c:\cygwin on my Windows XP system.
 - Downloaded latest cygwin libcurl "devel" distribution
curl-devel-7.11.1-1-cygwin.tar.bz2
 - Unzipped, placing the provided "lib" and "include" files into the cygwin
distribution. This yielded
  c:\cygwin\lib\libcurl.a c:\cygwin\lib\libcurl.dll.a c:\cygwin\lib\libcurl.la

 c:\cygwin\include\curl\curl.h c:\cygwin\include\curl\easy.h
c:\cygwin\include\curl\mprintf.h
c:\cygwin\include\curl\multi.h c:\cygwin\include\curl\stdcheaders.h
c:\cygwin\include\curl\types.h
 - Used the "simple" example provided in the cygwin distribution and called
it "test.cc"
  
#include <curl/curl.h>

#include <stdio.h>

/*

static int fn_append(char * data, size_t item_size, size_t item_count,

string* buffer) {

if (buffer == NULL) return 0;

buffer->append(data, item_size*item_count);

return item_size*item_count;

}

*/

#include <stdio.h>

#include <curl/curl.h>

int main(void)

{

CURL *curl;

CURLcode res;

curl = curl_easy_init();

if(curl) {

curl_easy_setopt(curl, CURLOPT_URL, "curl.haxx.se <http://curl.haxx.se>");

res = curl_easy_perform(curl);

/* always cleanup */

curl_easy_cleanup(curl);

}

return 0;

}

  - Finally, went to the command line and tried compiling:

 gcc -lcurl -L/cygwin/usr/lib test.cc

Here's what keeps coming back:

 /cygdrive/c/DOCUME~1/cscaffid/LOCALS~1/Temp/cc8pG9Kx.o(.text+0x1f):test.cc:
undefined reference to `
_curl_easy_init'
/cygdrive/c/DOCUME~1/cscaffid/LOCALS~1/Temp/cc8pG9Kx.o(.text+0x43):test.cc:
undefined reference to `
_curl_easy_setopt'
/cygdrive/c/DOCUME~1/cscaffid/LOCALS~1/Temp/cc8pG9Kx.o(.text+0x4e):test.cc:
undefined reference to `
_curl_easy_perform'
/cygdrive/c/DOCUME~1/cscaffid/LOCALS~1/Temp/cc8pG9Kx.o(.text+0x5c):test.cc:
undefined reference to `
_curl_easy_cleanup'
collect2: ld returned 1 exit status

  I have tried using MinGW instead (with the corresponding libcurl
distribution) and got essentially the same error. If I change the "-lcurl"
command to "-lcurlgarbage", then the linker rightly complains that it cannot
find the archive; so I infer that it is indeed successfully finding the
archive, but is simply choosing not to use it. Please help!!!
Received on 2005-05-23