cpr icon indicating copy to clipboard operation
cpr copied to clipboard

Is there a way to build and add the `cpr` lib without CMake or any package manager ?

Open ssantos21 opened this issue 2 years ago • 2 comments

Is there a way to build and add the cpr lib without CMake or any package manager ?

I ran the following commands as per README:

$ sudo apt install -y libcurl4-openssl-dev
$ git clone https://github.com/libcpr/cpr.git
$ cd cpr && mkdir build && cd build
$ cmake .. -DCPR_USE_SYSTEM_CURL=ON
$ cmake --build .
$ sudo cmake --install .

So created the client.cpp file:

#include <cpr/cpr.h>

int main() {
    cpr::Response r = cpr::Get(cpr::Url{"http://www.httpbin.org/get"},
        cpr::Parameters{{"hello", "world"}});
    return 0;
}

And built it:

g++ -std=c++20 client.cpp -lcpr -lcurl -o client_bin

But when I run .\client_bin I get the error:

./client_bin: error while loading shared libraries: libcpr.so.1: cannot open shared object file: No such file or directory

How can I use this project without relaying on CMake or any package manager ?

OS: Ubuntu 22.04 GCC version: 11.3.0

ssantos21 avatar Jul 13 '23 01:07 ssantos21

This was apparently resolved by running ldconfig.

https://stackoverflow.com/a/13132584

ssantos21 avatar Jul 13 '23 16:07 ssantos21

@ssantos21 I'm glad you solved it! Using ldconfig is something we should document. I will keep this issue open until we have done so. Thanks for reporting.

COM8 avatar Jul 13 '23 16:07 COM8