我正在尝试将curl添加到我的项目上的codeblocks(Windows 10)。我在链接器设置中链接了libcurl的.a文件,并在搜索目录中添加了include文件。但是,当我尝试运行示例代码时
#include <stdio.h>
#include <iostream>
#include <json.hpp>
#include <curl/curl.h>
using namespace std;
int main()
{
CURL *curl;
CURLcode res;
curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
/* example.com is redirected, so we tell libcurl to follow redirection */
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
/* Perform the request, res will get the return code */
res = curl_easy_perform(curl);
/* Check for errors */
if(res != CURLE_OK)
fprintf(stderr, "curl_easy_perform() failed: %s\n",
curl_easy_strerror(res));
/* always cleanup */
curl_easy_cleanup(curl);
}
return 0;
}
但我仍然遇到一堆错误(不介意我的用户名)
||=== Build: Debug in LeagueAssistant (compiler: GNU GCC Compiler) ===|
obj\Debug\main.o||In function `main':|
C:\Users\THE YUNG T-SCAGS\Desktop\programming projects\LeagueAssistant\main.cpp|13|undefined reference to `_imp__curl_easy_init'|
C:\Users\THE YUNG T-SCAGS\Desktop\programming projects\LeagueAssistant\main.cpp|15|undefined reference to `_imp__curl_easy_setopt'|
C:\Users\THE YUNG T-SCAGS\Desktop\programming projects\LeagueAssistant\main.cpp|17|undefined reference to `_imp__curl_easy_setopt'|
C:\Users\THE YUNG T-SCAGS\Desktop\programming projects\LeagueAssistant\main.cpp|20|undefined reference to `_imp__curl_easy_perform'|
C:\Users\THE YUNG T-SCAGS\Desktop\programming projects\LeagueAssistant\main.cpp|23|undefined reference to `_imp__curl_easy_strerror'|
C:\Users\THE YUNG T-SCAGS\Desktop\programming projects\LeagueAssistant\main.cpp|27|undefined reference to `_imp__curl_easy_cleanup'|
||error: ld returned 1 exit status|
||=== Build failed: 7 error(s), 0 warning(s) (0 minute(s), 1 second(s)) ===|
任何人都知道会出现什么问题?