(我看到一個類似的問題,但它是2歲。)ld.exe找不到-lcurl
我正在開發一個Windows窗體應用程序在Visual C++ 2008,它使用的FTP功能libcurl的。儘管我已經將lib和include目錄添加到包含和庫搜索路徑中,但將libcurl_imp.lib添加到其他依賴項並將CURL_STATICLIB添加到預處理程序定義中,但是在構建它時會出現14個鏈接程序錯誤。我檢查了cURL FAQ和谷歌的一些錯誤,但我還沒有找到解決方案。鏈接器錯誤如下:(我削除項目名稱)
1>-------.obj : error LNK2031: unable to generate p/invoke for "extern "C" void __clrcall curl_easy_cleanup(void *)" ([email protected]@[email protected]); calling convention missing in metadata
1>-------.obj : error LNK2031: unable to generate p/invoke for "extern "C" enum CURLcode __clrcall curl_easy_perform(void *)" ([email protected]@[email protected]@[email protected]); calling convention missing in metadata
1>-------.obj : error LNK2031: unable to generate p/invoke for "extern "C" enum CURLcode __clrcall curl_easy_setopt(void *,enum CURLoption,...)" ([email protected]@[email protected]@[email protected]@ZZ); calling convention missing in metadata
1>-------.obj : error LNK2031: unable to generate p/invoke for "extern "C" void * __clrcall curl_easy_init(void)" ([email protected]@$$J0YMPAXXZ); calling convention missing in metadata
1>-------.obj : error LNK2028: unresolved token (0A00000E) "extern "C" void __clrcall curl_easy_cleanup(void *)" ([email protected]@[email protected]) referenced in function "int __clrcall main(cli::array<class System::String^>^)" ([email protected]@[email protected]@@@Z)
1>-------.obj : error LNK2028: unresolved token (0A00000F) "extern "C" enum CURLcode __clrcall curl_easy_perform(void *)" ([email protected]@[email protected]@[email protected]) referenced in function "int __clrcall main(cli::array<class System::String^>^)" ([email protected]@[email protected]@@@Z)
1>-------.obj : error LNK2020: unresolved token (0A000010) "extern "C" enum CURLcode __clrcall curl_easy_setopt(void *,enum CURLoption,...)" ([email protected]@[email protected]@[email protected]@ZZ)
1>-------.obj : error LNK2020: unresolved token (0A000011) "extern "C" enum CURLcode __clrcall curl_easy_setopt(void *,enum CURLoption,...)" ([email protected]@[email protected]@[email protected]@ZZ)
1>-------.obj : error LNK2028: unresolved token (0A000012) "extern "C" void * __clrcall curl_easy_init(void)" ([email protected]@$$J0YMPAXXZ) referenced in function "int __clrcall main(cli::array<class System::String^>^)" ([email protected]@[email protected]@@@Z)
1>-------.obj : error LNK2019: unresolved external symbol "extern "C" void __clrcall curl_easy_cleanup(void *)" ([email protected]@[email protected]) referenced in function "int __clrcall main(cli::array<class System::String^>^)" ([email protected]@[email protected]@@@Z)
1>-------.obj : error LNK2019: unresolved external symbol "extern "C" enum CURLcode __clrcall curl_easy_perform(void *)" ([email protected]@[email protected]@[email protected]) referenced in function "int __clrcall main(cli::array<class System::String^>^)" ([email protected]@[email protected]@@@Z)
1>-------.obj : error LNK2001: unresolved external symbol "extern "C" enum CURLcode __clrcall curl_easy_setopt(void *,enum CURLoption,...)" ([email protected]@[email protected]@[email protected]@ZZ)
1>-------.obj : error LNK2019: unresolved external symbol "extern "C" void * __clrcall curl_easy_init(void)" ([email protected]@$$J0YMPAXXZ) referenced in function "int __clrcall main(cli::array<class System::String^>^)" ([email protected]@[email protected]@@@Z)
是什麼造成這一點,我該怎麼預防呢?謝謝:)
UPDATE
我切換到代碼::塊,現在它的本機Win32 GUI應用程序。我不明白所有這些鏈接錯誤,但我得到的東西:
ld.exe cannot find -lcurl.lib
而不是添加包括和lib目錄到搜索目錄,我只是把它們放在我的項目目錄。我很困惑這個錯誤,因爲lib的名字是libcurl.lib,而不是curl.lib。關於發生了什麼的任何想法?
編輯:抱歉,所有的編輯,我只是想提到,我將libcurl.lib添加到鏈接庫。
UPDATE
現在我已經添加-lcurl到其他鏈接選項對話框中的錯誤已更改爲
ld.exe cannot find -lcurl
沒有.LIB部分。
唯一的lib文件是libcurl.lib,並且位於項目文件夾中。將項目文件夾添加到鏈接程序搜索路徑中並沒有做任何事情。這肯定是32位,但我不確定單個和多線程部分。 – 2011-02-13 15:39:29