c++ - 链接 libcurl 问题

标签 c++ gcc ubuntu g++

我正在尝试在 ubuntu 上编译一个需要 libcurl 的 C++ 项目。

我已经安装了以下软件包:

libcurl4-gnutls-dev

运行“pkg-config --libs curl”返回:

-lcurl

运行“curl-config --libs”返回:

-L/usr/lib/i386-linux-gnu -lcurl

这是我的 g++ 构建命令行:

g++ -lboost_program_options -pthread -L/usr/lib/i386-linux-gnu -lcurl main.cpp

这些是我遇到的错误:

main.cpp:(.text+0x374): undefined reference to `curl_easy_init'
main.cpp:(.text+0x416): undefined reference to `curl_easy_setopt'
main.cpp:(.text+0x434): undefined reference to `curl_easy_setopt'
main.cpp:(.text+0x442): undefined reference to `curl_easy_perform'
main.cpp:(.text+0x450): undefined reference to `curl_easy_cleanup'

我该如何解决这个问题?

最佳答案

参数顺序在 g++ 命令中很重要,尝试:

g++ main.cpp -L/usr/lib/i386-linux-gnu -lboost_program_options -pthread  -lcurl 

关于c++ - 链接 libcurl 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14554884/

相关文章:

c++ - 将小端顺序的 4 个字节转换为无符号整数

C++ 模板类语法

gcc - Windows 下 Eclipse 的 GNU ARM 插件 - OpenOCD 未开始调试

ubuntu - 找不到 Ubuntu 树的 hvm 内核

ubuntu 卡在 initramfs 内核 panic 退出代码 0x00000100

c++ - 在 C++ 中创建用户列表

c++ - 删除复制构造函数是否也会删除默认的复制/移动运算符?

gcc - 编译,使用内联源生成程序集,无需调用 objdump

c - Strcat 堆栈粉碎行为

python - 从 Windows 访问 ubuntu 文件(安装在 virtualbox 中)