如何在QT创建项目中使用RESTCLIENT-CPP
How can i use restclient-cpp in a Qt creator project?
我正在研究我的第一个QT项目。我需要访问REST API,并决定给予https://github.com/mrtazz/restclient-cpp a尝试。
问题是我无法使它起作用。构建项目时,我会遇到此错误:
Undefined symbols for architecture x86_64:
"RestClient::get(std::string const&)", referenced from:
_main in main.o
ld: symbol(s) not found for architecture x86_64
我不确定这是否正确。但是我下载了RestClient-CPP并卷曲到3rdparty/libs文件夹中。
之后,在我的.pro文件中添加了以下代码:
LIBS += -L"$$_PRO_FILE_PWD_/3rdparty/libs/"
INCLUDEPATH += "$$_PRO_FILE_PWD_/3rdparty/libs/"
在main.cpp中添加:
#include <restclient-cpp/include/restclient.h>
,当我将以下行添加到我的代码中时发生错误:
RestClient::response r = RestClient::get("http://localhost/customers");
没有这条线,至少我可以构建项目。
正确的方法是什么?
其他信息
这是我的文件夹结构:
bash-3.2$ cd 3rdparty/libs/
bash-3.2$ ls -lh
total 0
drwxr-xr-x@ 42 fernando staff 1,4K 24 Jan 23:30 curl
drwxr-xr-x 34 fernando staff 1,1K 24 Jan 23:57 restclient-cpp
bash-3.2$ cd restclient-cpp/
bash-3.2$ ls
LICENSE README.md config.guess config.status depcomp libtool stamp-h1
Makefile aclocal.m4 config.h config.sub include ltmain.sh test
Makefile.am autom4te.cache config.h.in configure install-sh missing utils
Makefile.in compile config.log configure.ac librestclient-cpp.la source vendor
我编译了卷曲和静止。Curl用基本的./configure&amp;&amp;制作。restclient编译了:
autoreconf -vif
./configure
make
安装curl(示例):
- 安装libcurl。开放终端并发出命令" sudo apt-get install curl",而无需Qoutes。
- 再次在您的终端中执行此操作:
- " sudo apt-get安装libcurl4-openssl-dev"
- " sudo apt-get安装libcurl4-gnutls-dev"
- " sudo apt-get安装libcurl4-nss-dev"
insall restclient-cpp:
- ./autogen.sh
- ./配置
- 使安装
我的.pro文件示例:
# Add restclient-cpp
LIBS += -L/usr/local/lib/ -lrestclient-cpp
,然后添加:
#include "restclient.h"
相关文章:
- .cpp和.h文件中的模板专用化声明
- 为什么两个不同的未命名名称空间可以共存于一个cpp文件中
- Linux的Cpp上的计时器
- 如何运行位于boost/libs/python/example/tutorial目录中的hello.cpp和Jamfil
- 命名空间中具有.h和.cpp文件的类
- 内置函数可查看CPP中的成员变量
- 无法编译 rtmidi 测试 cmidiin.cpp 文件, 非法指令
- Cpp-Tuple使用带有变量的get
- C++-试图将函数指针推回到另一个CPP文件中的矢量时出错
- 有充分的理由在h文件中使用include保护而不是cpp文件吗
- 如何通过cpp程序运行shell脚本
- 使用2个键的cpp-stl::优先级队列排序不正确
- cpp二进制搜索问题,计算给定数组中输入元素的出现次数
- 如何在cpp文件之间切换窗口?在Qt中
- 在 .h 文件中的类中声明静态变量和在.cpp文件中声明"global"变量有什么区别
- 我需要知道编译器如何在cpp中使用析构函数
- 如何在cpp.中使用协议缓冲区存储大缓冲区/数组(char/int)
- 如何在QT创建项目中使用RESTCLIENT-CPP
- 带有restclient cpp的JSON属性树
- 在Cygwin上编译restclient cpp不会构建共享库