1

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.

Cliffniff
  • 400
  • 1
  • 4
  • 13
  • Depends on how you build your C++-project. cpr has documentation for CMake. What do you use? – Gerriet Oct 13 '19 at 09:34
  • _"there are no easy pkg managers like pip to install libraries in C++"_. That's not true. There are build systems: CMake, SCons, qmake, bjam, ... and package managers: Conan, Buckaroo, hunter, vcpkg, .... – Thomas Sablik Oct 13 '19 at 13:14

3 Answers3

3

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.

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

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>

And build it like so:

g++ -std=c++11 -o main -lcpr main.cpp
Jon
  • 126
  • 3
0

You can always try old-ways and use header files directly. Most likely, under the hood it all comes down to some call like "gcc ......." and to get an idea of how to put together the proper build list for cpr try looking at their travis.yml https://github.com/whoshuu/cpr/blob/master/.travis.yml or how their Cmake calls are made.

You need CPR

0

incase you have an erorr like - make: *** No targets specified and no makefile found. Stop.

try running this command on ubuntu os: sudo apt-get install libssl-dev

i referenced this article: CMake not able to find OpenSSL library

Dharman
  • 30,962
  • 25
  • 85
  • 135
CrummY
  • 1
  • 2
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Nov 30 '21 at 16:04