本文介绍了如何在C ++中使用CPR库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我以前是用python开发的,现在我已切换到C ++.我找到了一个很酷的库,叫做CPR https://github.com/whoshuu/cpr 使HTTP请求像python请求一样容易.像在python中一样,没有像pip这样的简单pkg管理器可以在C ++中安装库.如何在我的项目中使用cpr.其中没有dll或lib文件.

I was previously developing in python and now I've switched to C++. I found a cool library called CPR https://github.com/whoshuu/cpr that can be used to make HTTP requests easily like python requests. Like in python there are no easy pkg managers like pip to install libraries in C++. How can I use cpr in my project. There are no dlls or lib file in that.

推荐答案

c ++ 程序包通常作为一组开发标头和静态/共享库分发.但是,对于 cpr 文档建议使用子模块将功能添加到您的项目中.

c++ packages are usually distributed as a set of development headers and static/shared libraries. However in the case of cpr, the documentation recommends to use submodules to get the functionality into your project.

由于 cpr 使用 cmake ,我也希望这是可能的(尽管没有记录):

As cpr uses cmake, I would also expect this to be possible (although not documented):

$ git clone https://github.com/whoshuu/cpr.git
$ cd cpr
$ mkdir build && cd build
$ cmake ..
$ make
$ make install

然后 cpr 将在您的系统中可用(只要 make install 将已构建的库和开发标头复制到系统范围内).在您的项目中,您将可以像这样包含 cpr :

Then cpr will be available in your system (as long as make install copies the built libraries and development headers to system-wide location). In your project, you will be able to include cpr like so:

#include <cpr/cpr.h>

并像这样构建它:

g++ -std=c++11 -o main -lcpr main.cpp

这篇关于如何在C ++中使用CPR库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 09:42