2011-03-30 25 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 

私はLinuxでこの問題を抱えていないので、なぜこれがウィンドウで起こるのか分かりません。私はすでにそれをgoogledして、同じ質問をして "google it"と答える返信用のメーリングリストのアーカイブ以外のものは見つけられませんでした。これらのlibcurlリンクエラーを解決するにはどうすればよいですか?

私はmingwを使用しています。 libcurlをビルドしたときにリンカの警告が表示されましたが、ssl関連のように見えました。エラーなしでビルドされているため、大きな問題であるかどうかはわかりません。

*** 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

Libtoolは動的ライブラリではなく、静的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'フラグが他のライブラリ(OpenSSLのように見えますが、おそらく1つまたは2つの他のもの)に必要です。 –

7

私はオプション-lcurl.dllを追加することにより、(mingwのWin32の)窓のエラーを結ぶこれらのカールを避けることができた。-DCURL_STATICLIBは、私の場合には必要とされていませんでした。

私のビルドは2を持っていますmingw/libフォルダ内のlibcurlファイル:libcurl.a and libcurl.dll.a

+1

私の問題を解決するbreadcrumbをありがとうg ++:コード::ブロック>設定>コンパイラ>リンカ設定>追加> lib \ libcurldll.a && lib \ libcurl.a –

1

mingwとnetbeans 7.1を使用して同じ問題が発生していました。プロパティから、ライブラリlibcurl.dll.aを追加しているリンカが私の問題を解決しました。

このファイルは、mingw makeを実行した後、curl-7.28.1 \ lib.libsの下にあります。

0

私は、さまざまなプロジェクトで(libzとlibsqliteで)同様のエラーが発生しました。 GNU libtoolスクリプトで作成されています。

私のケースでは、これらのライブラリ(.la?)またはライブラリのlibz.dll.aバリアントのファイルが不足していました。 automakeは/ autoconfのビルド./configure --prefix=... ; makeために必要なすべてのファイルを持っている

、あなたは同じMSYSの下にconfiguremakezlibcryptosslを構築する必要があります。 cmakeまたはカスタムmakefileビルドは、通常、共有ライブラリautotoolビルドの依存関係としては機能しません。

別の最も簡単なオプションは、cmakeの(https://github.com/bagder/curl.git)と動的なカールを構築することです

関連する問題