无法在code :: blocks

时间:2017-04-04 05:41:14

标签: c++ libcurl

我已成功在我的Windows计算机上安装了cURL。我可以在控制台中成功运行cURL命令。但是,在Windows中,我得到了一堆"未定义的引用"运行此代码时出错:



#include <stdio.h>
#include <curl/curl.h>
int main(void)
{
    CURL *curl;
    CURLcode res;
    const char* szURL = "https://na.api.pvp.net/api/lol/na/v1.4/summoner/by-name/TheCarpStandsUp?api_key=RGAPI-40d6fff4-cc4c-467b-8c06-96ac90878ae4";

    curl_global_init(CURL_GLOBAL_DEFAULT);
    curl = curl_easy_init();
    if(curl) {
        curl_easy_setopt(curl, CURLOPT_URL, szURL);

    /* 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);
    }

    curl_global_cleanup();
    return 0;
}
&#13;
&#13;
&#13;

当我尝试编译时,我收到以下错误

&#13;
&#13;
||=== 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|11|undefined reference to `_imp__curl_global_init'|
C:\Users\THE YUNG T-SCAGS\Desktop\programming projects\LeagueAssistant\main.cpp|12|undefined reference to `_imp__curl_easy_init'|
C:\Users\THE YUNG T-SCAGS\Desktop\programming projects\LeagueAssistant\main.cpp|14|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_perform'|
C:\Users\THE YUNG T-SCAGS\Desktop\programming projects\LeagueAssistant\main.cpp|21|undefined reference to `_imp__curl_easy_strerror'|
C:\Users\THE YUNG T-SCAGS\Desktop\programming projects\LeagueAssistant\main.cpp|25|undefined reference to `_imp__curl_easy_cleanup'|
C:\Users\THE YUNG T-SCAGS\Desktop\programming projects\LeagueAssistant\main.cpp|28|undefined reference to `_imp__curl_global_cleanup'|
||error: ld returned 1 exit status|
||=== Build failed: 8 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
&#13;
&#13;
&#13;

我已将libcurl.a文件添加到构建选项链接器设置中,并将include目录添加到搜索目录中。

0 个答案:

没有答案