954,496 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Libcurl with Cygwin/G++

Hi,
Can someone help me with the CURL library using GCC on Cygwin?
I can't find anything in the documents that explain exactly how to compile with g++.
For instance:
g++ -I curl CurlSample.cpp

gives me errors such as:
/tmp/ccrXZUYr.o:CurlSample.cpp:(.text+0x17): undefined reference to `_curl_easy_
init'

I'm using gcc version 4.3.4 ... all of the curl files are installed in the directory /usr/include/curl

Any help would be much appreciated... thanks!

JeremyJ
Newbie Poster
4 posts since Nov 2010
Reputation Points: 10
Solved Threads: 0
 

There should be a file called libcurl.so and/or a file called libcurl.a in the /usr/lib directory. You need to link one of them. I use the .so file, but I imagine it doesn't matter.

Here's a decent tutorial on linking shared objects.

http://www.yolinux.com/TUTORIALS/LibraryArchives-StaticAndDynamic.html

VernonDozier
Posting Expert
5,527 posts since Jan 2008
Reputation Points: 2,633
Solved Threads: 711
 

There should be a file called libcurl.so and/or a file called libcurl.a in the /usr/lib directory. You need to link one of them. I use the .so file, but I imagine it doesn't matter.

Here's a decent tutorial on linking shared objects.

http://www.yolinux.com/TUTORIALS/LibraryArchives-StaticAndDynamic.html

VernonDozier
Posting Expert
5,527 posts since Jan 2008
Reputation Points: 2,633
Solved Threads: 711
 

Thanks for the link, but I'm still not able to compile correctly.
I found libcurl.a, copied that to my directory, now what?

When I try to compile I still get error messages. Any suggestions?
$ cc -o CurlSample.exe CurlSample.cpp -L/libcurl.a

/tmp/ccjGDNTk.o:CurlSample.cpp:(.text+0x17): undefined reference to `_curl_easy_init'
/tmp/ccjGDNTk.o:CurlSample.cpp:(.text+0x3b): undefined reference to `_curl_easy_setopt'
/tmp/ccjGDNTk.o:CurlSample.cpp:(.text+0x46): undefined reference to `_curl_easy_perform'
/tmp/ccjGDNTk.o:CurlSample.cpp:(.text+0x54): undefined reference to `_curl_easy_cleanup'
/tmp/ccjGDNTk.o:CurlSample.cpp:(.eh_frame+0x11): undefined reference to `___gxx_personality_v0'
collect2: ld returned 1 exit status
Jeremy@jj-laptop /cygdrive/c/cygwin/home/Jeremy/project

There should be a file called libcurl.so and/or a file called libcurl.a in the /usr/lib directory. You need to link one of them. I use the .so file, but I imagine it doesn't matter.

Here's a decent tutorial on linking shared objects.

http://www.yolinux.com/TUTORIALS/LibraryArchives-StaticAndDynamic.html

JeremyJ
Newbie Poster
4 posts since Nov 2010
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: