为什么libcurl错误未定义引用

时间:2017-04-13 07:42:33

标签: c++ curl libcurl curlpp

我已经开始使用libcurl几个小时了。但它一次发生太多错误。这是我在main.cpp中的代码:

#include <iostream>
#include "curl-7.53.1/include/curl/curl.h"
using namespace std;

int main(int argc, char *argv[])
{
    CURL *curl;
    CURLcode res;
    curl_global_init(CURL_GLOBAL_ALL);
    curl = curl_easy_init();
    if(curl){
        curl_easy_setopt(curl, CURLOPT_URL, "http://localhost/like.php");
        curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "mediaId=4665");
        res = curl_easy_perform(curl);
        if(res!=CURLE_OK)
            cout«"something went wrong.";
        curl_easy_cleanup(curl);
    }
    curl_global_cleanup();
    return 0;
}

所以这些是错误:

/home/muhammad/Documents/Qt projects/untitled3/main.cpp:-1: error: undefined reference to `curl_global_init'
/home/muhammad/Documents/Qt projects/untitled3/main.cpp:-1: error: undefined reference to `curl_easy_init'
/home/muhammad/Documents/Qt projects/untitled3/main.cpp:-1: error: undefined reference to `curl_easy_setopt'
/home/muhammad/Documents/Qt projects/untitled3/main.cpp:-1: error: undefined reference to `curl_easy_setopt'
/home/muhammad/Documents/Qt projects/untitled3/main.cpp:-1: error: undefined reference to `curl_easy_perform'
/home/muhammad/Documents/Qt projects/untitled3/main.cpp:-1: error: undefined reference to `curl_easy_cleanup'
/home/muhammad/Documents/Qt projects/untitled3/main.cpp:-1: error: undefined reference to `curl_global_cleanup'

我该如何解决? (操作系统是linux ubuntu)

0 个答案:

没有答案