我安装了curl这个命令(我使用Ubuntu):
sudo apt-get install curl
Run Code Online (Sandbox Code Playgroud)
当我使用测试简单程序时 g++ test.cpp
#include <stdio.h>
#include <curl/curl.h>
int main(void)
{
CURL *curl;
CURLcode res;
curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
/* 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;
}
Run Code Online (Sandbox Code Playgroud)
g++ 告诉我:
fatal error: curl/curl.h: No such file or directory
compilation terminated.
Run Code Online (Sandbox Code Playgroud)
谁能帮我?
我需要在我在ubuntu机器上编写的一个软件中使用libcurl.我正在使用Eclipse编写和编译所有软件.当我将libcurl文件放在与.cpp文件相同的文件夹中,并在标题中包含curl.h文件时,当我尝试编译程序时,它会出现以下错误:
Building target: sms
Invoking: GCC C++ Linker
g++ -o"sms" ./src/sms.o
./src/sms.o: In function `main':
/home/geekman/workspace/sms/Debug/../src/sms.cpp:38: undefined reference to `curl_easy_init'
/home/geekman/workspace/sms/Debug/../src/sms.cpp:42: undefined reference to `curl_easy_setopt'
/home/geekman/workspace/sms/Debug/../src/sms.cpp:44: undefined reference to `curl_easy_setopt'
/home/geekman/workspace/sms/Debug/../src/sms.cpp:46: undefined reference to `curl_easy_perform'
/home/geekman/workspace/sms/Debug/../src/sms.cpp:47: undefined reference to `curl_easy_cleanup'
collect2: ld returned 1 exit status
make: *** [sms] Error 1
Run Code Online (Sandbox Code Playgroud)
我从libcurl中获取了include文件夹的内容,并将它们放在与.cpp文件相同的文件夹中.然后在.cpp文件的标题中,我键入:
#include <curl/curl.h>
Run Code Online (Sandbox Code Playgroud)
我也尝试过:
#include "curl/curl.h"
Run Code Online (Sandbox Code Playgroud)
关于这个问题的任何想法?谢谢.
我正在 Ubuntu 上使用 Curl 开发 C 程序。我正在使用 Eclipse 开普勒。我已经使用安装了 curl 库
apt-get install libcurl4-gnutls-dev
我检查了一切是否正常使用
ls -l /usr/include/curl
我有
共 172 个
-rw-r--r-- 1 根 7065 janv。31 16:49 curlbuild.h
-rw-r--r-- 1 根 81593 janv. 31 16:49 curl.h
-rw-r--r-- 1 根根 8901 janv。31 16:49 curlrules.h
-rw-r--r-- 1 根根 2741 janv。31 16:49 curlver.h
-rw-r--r-- 1 根根 3472 janv。31 16:49 easy.h
-rw-r--r-- 1 根根 2790 janv。31 16:49 mprintf.h
-rw-r--r-- 1 根根 12981 janv。31 16:49 多小时
-rw-r--r-- 1 根 1330 janv。31 16:49 stdcheaders.h
-rw-r--r-- …