visual C++ 2015報錯:error LNK2019: unresolved external symbol __imp__curl_global_init referenced in

2020-08-12 10:33:12

太難了,報了一堆錯~

1>HttpClient.obj : error LNK2019: unresolved external symbol __imp__curl_global_init referenced in function 「public: __thiscall CHttpClient::CHttpClient(void)」 (??0CHttpClient@@QAE@XZ)
1>HttpClient.obj : error LNK2019: unresolved external symbol __imp__curl_easy_init referenced in function 「public: __thiscall CHttpClient::CHttpClient(void)」 (??0CHttpClient@@QAE@XZ)
1>HttpClient.obj : error LNK2019: unresolved external symbol __imp__curl_easy_setopt referenced in function 「public: int __thiscall CHttpClient::Get(class std::basic_string<char,struct std::char_traits,class std::allocator > const &,class std::basic_string<char,struct std::char_traits,class std::allocator > &)」 (?Get@CHttpClient@@QAEHABV?basicstring@DU?basic_string@DU?char_traits@D@std@@V?KaTeX parse error: Expected group after '_' at position 92: …xternal symbol _̲_imp__curl_easy…basic_string@DU?chartraits@D@std@@V?char_traits@D@std@@V?allocator@D@2@@std@@AAV23@@Z)
1>HttpClient.obj : error LNK2019: unresolved external symbol __imp__curl_easy_cleanup referenced in function 「public: __thiscall CHttpClient::~CHttpClient(void)」 (??1CHttpClient@@QAE@XZ)

如圖所示:
在这里插入图片描述

解決方案:
在properties->C/C+±>preprocessor->preprocessor Definitions處加上以下欄位:
BUILDING_LIBCURL;HTTP_ONLY

  如圖所示:

在这里插入图片描述
別忘了加上curl的鏈接庫~
大家呼叫curl的時候一定要小心噢~