我现在已经收到这个错误了一段时间,所以作为最后的手段,我跟着This video到了这封信......但仍然有同样的错误。所以,这是我制作的代码:
#include <iostream>
#include <string>
#define CURL_STATIC
#include "curl/curl.h"
#ifdef _DEBUG
# pragma comment (lib, "curl/libcurl_a_debug.lib")
#else
# pragma comment (lib, "curl/libcurl_debug.lib")
#endif
static int writer(char *data, size_t size, size_t nmemb,
std::string *writerData)
{
if (writerData == NULL)
return 0;
writerData->append(data, size*nmemb);
return size * nmemb;
}
int wmain(int argc, wchar_t *argv[], wchar_t *envp[])
{
std::cout << "Hello curl!";
std::string content;
curl_global_init(CURL_GLOBAL_ALL);
CURL *curl = nullptr;
curl = curl_easy_init();
if (curl)
{
curl_easy_setopt(curl, CURLOPT_URL, "https://www.youtube.com/watch?v=wjNyT5PhNvI&t=417s");
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &content);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writer);
CURLcode code = curl_easy_perform(curl);
curl_easy_cleanup(curl);
}
curl_global_cleanup();
std::cout << content;
std::cin.get();
}
错误:
1>------ Build started: Project: curl_test, Configuration: Debug Win32 ------
1>main.cpp
1>main.obj : error LNK2019: unresolved external symbol __imp__curl_global_init referenced in function _wmain
1>main.obj : error LNK2019: unresolved external symbol __imp__curl_global_cleanup referenced in function _wmain
1>main.obj : error LNK2019: unresolved external symbol __imp__curl_easy_init referenced in function _wmain
1>main.obj : error LNK2019: unresolved external symbol __imp__curl_easy_setopt referenced in function _wmain
1>main.obj : error LNK2019: unresolved external symbol __imp__curl_easy_perform referenced in function _wmain
1>main.obj : error LNK2019: unresolved external symbol __imp__curl_easy_cleanup referenced in function _wmain
1>c:\users\james\source\repos\curl_test\Debug\curl_test.exe : fatal error LNK1120: 6 unresolved externals
1>Done building project "curl_test.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
有谁知道造成这种情况的原因是什么? Linker susbsytem设置为console,字符集设置为unicode,MFC设置为在静态库中使用。