Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Reply-To: Cygwin List Message-Id: <6.1.0.6.0.20041107130528.041386c0@pop.prospeed.net> X-Sender: Date: Sun, 07 Nov 2004 13:13:53 -0500 To: "Jason Riffel" , cygwin AT cygwin DOT com From: Larry Hall Subject: Re: Problems linking against libcurl under cygwin In-Reply-To: <23508.69.170.37.57.1099849565.squirrel@69.170.37.57> References: <23508 DOT 69 DOT 170 DOT 37 DOT 57 DOT 1099849565 DOT squirrel AT 69 DOT 170 DOT 37 DOT 57> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" At 12:46 PM 11/7/2004, you wrote: >Hi - New to Cygwin for development, not new to development. > >Have a project that uses libcurl which will not link under Cygwin. All of the >basic libcurl APIs show up as unresolved in the link process. > >Example: > >gcc -L/usr/local/lib -lcurl -shared ../../shared/htmlparse/htmlparse.o ../../sha >red/wwwfetch/wwwfetch.o ../shared/free.o key.o -o key.so >key.o(.text+0x3ae):key.c: undefined reference to `_curl_global_init' >key.o(.text+0x3b3):key.c: undefined reference to `_curl_easy_init' >key.o(.text+0x420):key.c: undefined reference to `_curl_easy_setopt' >key.o(.text+0x42b):key.c: undefined reference to `_curl_easy_perform' >key.o(.text+0x436):key.c: undefined reference to `_curl_easy_cleanup' >collect2: ld returned 1 exit status >make: *** [key.so] Error 1 > >I believe I have checked all the obvious things. > >1) libcurl.a is located in /lib >2) libcurl is in my library path (obviously) >3) libcurl.a is being linked against (if I change -lcurl to -lcurlx I get an >error for not finding the library) >4) I've tried using both libcurl binaries from Cygwin and building libcurl >from sources >5) I also tried linking against libcurl.dll.a as well, makes no difference. > >This same code links, runs, etc under FreeBSD and Linux just fine. > >Are there special linking requirements under Cygwin or something obvious I'm >missing? You're missing the importance of link order. See 'man ld'. I created the following small example: # cat t.c #include int main() { curl_global_init(0); return 0; } # gcc -c t.c # gcc -lcurl -shared ./t.o -o t.so ./t.o(.text+0x26):t.c: undefined reference to `_curl_global_init' collect2: ld returned 1 exit status # gcc --shared -o t.so ./t.o -lcurl # BTW, it's recommended that you not use the '.so' extension on Windows. Windows creates DLLs, not shared objects. Using '.so' as the extension may or may not be a problem for you in your case. But it is something you should be aware of. BTW, if it is not obvious from the above, your link problem is not a Cygwin issue. You'd see this link problem on the other platforms you mentioned. -- Larry Hall http://www.rfk.com RFK Partners, Inc. (508) 893-9779 - RFK Office 838 Washington Street (508) 893-9889 - FAX Holliston, MA 01746 -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/