2011-03-30 15 views
6
[[email protected] ~]$ g++ client.cpp -lcurl -o client.exe 
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\ccKXFUtC.o:client.cpp:(.text+0x23): undefined reference to `_imp__curl_global_init' 
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\ccKXFUtC.o:client.cpp:(.text+0x5f): undefined reference to `_imp__curl_formadd' 
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\ccKXFUtC.o:client.cpp:(.text+0x9b): undefined reference to `_imp__curl_formadd' 
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\ccKXFUtC.o:client.cpp:(.text+0xa2): undefined reference to `_imp__curl_easy_init' 
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\ccKXFUtC.o:client.cpp:(.text+0xc8): undefined reference to `_imp__curl_easy_setopt' 
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\ccKXFUtC.o:client.cpp:(.text+0xe4): undefined reference to `_imp__curl_easy_setopt' 
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\ccKXFUtC.o:client.cpp:(.text+0xf1): undefined reference to `_imp__curl_easy_perform' 
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\ccKXFUtC.o:client.cpp:(.text+0x101): undefined reference to `_imp__curl_easy_cleanup' 
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\ccKXFUtC.o:client.cpp:(.text+0x10e): undefined reference to `_imp__curl_formfree' 
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\ccKXFUtC.o:client.cpp:(.text+0x11b): undefined reference to `_imp__curl_slist_free_all' 
collect2: ld returned 1 exit status 

मुझे लिनक्स पर यह समस्या नहीं है इसलिए मुझे नहीं पता कि यह विंडोज़ पर क्यों होता है। मैंने इसे पहले से गुमराह किया था और उसी प्रश्न के साथ मेलिंग सूची अभिलेखागार को छोड़कर कुछ भी नहीं मिला और "google it" कहने का उत्तर दिया।मैं इन libcurl लिंकिंग त्रुटियों को कैसे हल करूं?

मैं mingw का उपयोग कर रहा हूँ। जब मैंने libcurl बनाया था तो मुझे कुछ लिंकर चेतावनियां मिलीं लेकिन वे एसएसएल से संबंधित लग रहे थे और मुझे नहीं पता कि यह एक बड़ा सौदा है क्योंकि यह त्रुटियों के बिना बनाया गया है।

*** Warning: linker path does not have real file for library -lssl. 
*** I have the capability to make that library automatically link in when 
*** you link to this library. But I can only do this if you have a 
*** shared version of the library, which you do not appear to have 
*** because I did check the linker path looking for a file starting 
*** with libssl and none of the candidates passed a file format test 
*** using a file magic. Last file checked: /ssl/lib/libssl.a 

*** Warning: linker path does not have real file for library -lcrypto. 
*** I have the capability to make that library automatically link in when 
*** you link to this library. But I can only do this if you have a 
*** shared version of the library, which you do not appear to have 
*** because I did check the linker path looking for a file starting 
*** with libcrypto and none of the candidates passed a file format test 
*** using a file magic. Last file checked: /ssl/lib/libcrypto.a 

*** Warning: linker path does not have real file for library -lz. 
*** I have the capability to make that library automatically link in when 
*** you link to this library. But I can only do this if you have a 
*** shared version of the library, which you do not appear to have 
*** because I did check the linker path looking for a file starting 
*** with libz and none of the candidates passed a file format test 
*** using a file magic. Last file checked: /mingw/lib//libz.a 
*** The inter-library dependencies that have been dropped here will be 
*** automatically added whenever a program is linked with this library 
*** or is declared to -dlopen it. 

*** Since this library must not contain undefined symbols, 
*** because either the platform does not support them or 
*** it was explicitly requested with -no-undefined, 
*** libtool will only create a static version of it. 

उत्तर

6

लिबेटोल ने केवल एक स्थिर libcurl बनाया और गतिशील पुस्तकालय नहीं बनाया। आपके हेडर गतिशील libcurl की तलाश में हैं। यह शायद libcurl की गलती नहीं है, क्योंकि मैं हेडर का समर्थन करता है कि में कोड देख सकते हैं __declspec(dllimport) और __declspec(dllexport) (कि एक अच्छा संकेत पैकेज लेखक जानता है क्या क्या है

तकनीकी विवरण:।। see this answer regarding libssh

समाधान: -DCURL_STATICLIB साथ संकलित करें।

+0

हम्म साथ गतिशील कर्ल निर्माण करना है। मैंने सोचा कि libcurl स्थिर और गतिशील दोनों बनाया गया है। मैं -DCURL_STATICLIB की कोशिश की लेकिन अब मैं लिंकर त्रुटियों के सैकड़ों WSAStartup को अपरिभाषित संदर्भ @ 8, _imp__ares_library_init कहना मिलता है, ntohs @ 4, getsockopt @ 20 आदि – VVV

+0

http://www.nomorepasting.com/getpaste.php?pasteid= 36044 – VVV

+1

आप किसी भी निर्भर पुस्तकालय में लिंक नहीं कर रहे हैं। आपको अन्य पुस्तकालयों के लिए 'कम से कम) -lwinsock2' प्लस जो भी' -l' झंडे की आवश्यकता होगी (यह ओपनएसएसएल और संभवतः एक या दो अन्य लोगों की तरह दिखता है) की आवश्यकता होगी। –

7

मैं विकल्प -lcurl.dll जोड़कर इन कर्ल खिड़कियां (MinGW Win32) पर त्रुटियों लिंक करने से बचने में सक्षम था। -DCURL_STATICLIB मेरे मामले में की जरूरत नहीं थी।

मेरे निर्माण दो है libcurl.a and libcurl.dll.a

+1

ब्रेडक्रंब के लिए धन्यवाद जो मेरी समस्या को हल करता है g ++: कोड :: ब्लॉक> सेटिंग्स> कंपाइलर> लिंकर सेटिंग्स> जोड़ें> lib \ libcurldll.a && lib \ libcurl.a –

1

MinGW साथ NetBeans 7.1 का उपयोग कर एक ही समस्या हो रही थी: MinGW/lib फ़ोल्डर में libcurl फ़ाइलें। गुणों से, लिंकर जोड़ने पुस्तकालय libcurl.dll.a मेरे लिए मुद्दा हल किया।

यह फ़ाइल कर्लिंग-7.28.1 \ lib.libs के तहत स्थित थी जब मैं मिंगव बनाने के बाद चला गया।

0

मुझे विभिन्न परियोजनाओं में समान त्रुटि (libz और libsqlite के साथ) थी। यह जीएनयू libtool लिपि द्वारा उत्पादित किया जाता है।

पुस्तकालयों के इन पुस्तकालयों (.la?) या शायद libz.dll.a भिन्नताओं के लिए मेरे मामले में कुछ फ़ाइलों की कमी थी।

automake/autoconf निर्माण ./configure --prefix=... ; make के लिए सभी आवश्यक फ़ाइलें के लिए, आपको zlib, configure साथ crypto और ssl और make के निर्माण करने के लिए एक ही MSYS के तहत होगा। सेमेक या कस्टम मेकफ़ाइल बिल्ड आमतौर पर साझा-लाइब्रेरी ऑटोोटूल बिल्ड के लिए निर्भरता के रूप में काम नहीं करेंगे।

एक और और सबसे आसान विकल्प cmake (https://github.com/bagder/curl.git)

संबंधित मुद्दे