c++ - 编译源代码时出现 cURLcpp 错误

标签 c++ curl makefile

我对 C++ 和 github 的使用有点陌生。 我想在 C++ 中使用 cURL 功能。因此,我首先从 github 中 fork curlcpp(由 JosephP91 编写),然后按照其 README.txt 中的说明进行操作。

现在执行时出现错误

make # -j2

(有或没有 -j2 没有区别)。

错误:

[ 12%] Building CXX object src/CMakeFiles/curlcpp.dir/curl_easy.cpp.o
In file included from /home/user/.git/curlcpp/src/curl_easy.cpp:6:0:
/home/user/.git/curlcpp/include/curl_easy.h:276:31: error: ‘CURLOPT_OBSOLETE72’ was not declared in this scope
         CURLCPP_DEFINE_OPTION(CURLOPT_OBSOLETE72, long); /* OBSOLETE, do not use! */
                               ^
/home/user/.git/curlcpp/include/curl_easy.h:47:33: note: in definition of macro ‘CURLCPP_DEFINE_OPTION’
     template <> struct option_t<opt> {\
                                 ^
/home/user/.git/curlcpp/include/curl_easy.h:47:36: error: template argument 1 is invalid
     template <> struct option_t<opt> {\
                                    ^
/home/user/.git/curlcpp/include/curl_easy.h:276:9: note: in expansion of macro ‘CURLCPP_DEFINE_OPTION’
         CURLCPP_DEFINE_OPTION(CURLOPT_OBSOLETE72, long); /* OBSOLETE, do not use! */
         ^
make[2]: *** [src/CMakeFiles/curlcpp.dir/curl_easy.cpp.o] Error 1
make[1]: *** [src/CMakeFiles/curlcpp.dir/all] Error 2
make: *** [all] Errors 2

在此先感谢大家对我的帮助!

编辑:

输出

cmake

输出:

-- The C compiler identification is GNU 4.8.2
-- The CXX compiler identification is GNU 4.8.2
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Found CURL: /usr/lib/x86_64-linux-gnu/libcurl.so (found suitable version "7.35.0", minimum required is "7.28.0") 
-- Configuring done
-- Generating done
-- Build files have been written to: /home/user/.git/curlcpp/build

最佳答案

您需要在 Ubuntu 上将 libcurl 从版本 7.35.0 更新到 7.37.1,在 utopic 存储库 (http://packages.ubuntu.com/utopic/libcurl4-nss-dev) 上可以使用 libcurl 7.31。

您可以使用 apt-get 进行更新:

echo "deb http://archive.ubuntu.com/ubuntu/ utopic main restricted" | sudo tee /etc/apt/sources.list
apt-get update
apt-get upgrade libcurl4-nss-dev

然后重做 cmake 和 make,它应该可以正常编译。

关于c++ - 编译源代码时出现 cURLcpp 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30189065/

相关文章:

c++ - Visual Studio Code 中的任务找不到文件

c++ - 基于系统架构的 C++ 中的类大小

c++ - 从可变参数模板中的一组仿函数中调用带有参数的函数

php - 下载 xml 时 curl 超时

c++ - g++ 无法找到此方法,即使它包含在内

c++ - 是否有可能获得股数?

php - 如何将 OAuth 与 PHP 和 cURL 结合使用?

php - 使用 PHP 在 NextCloud 中创建日历事件

qt - 使用Qt时出现 "missing separator"make错误是什么意思?

makefile - 如何避免覆盖目标或抑制警告