Issues in compiling cpr c++ library): undefined reference to `cpr::Parameters::Parameters(

Hello to everybody;
I just tried to use this example of cpr c++ library:


#include "cpr/cpr.h"

int main(int argc, char** argv) {
auto r = cpr::Get(cpr::Url{"https://api.github.com/repos/whoshuu/cpr/contributors"},
cpr::Authentication{"user", "pass"},
cpr::Parameters{{"anon", "true"}, {"key", "value"}});
}



Which I downloaded from https://github.com/whoshuu/cpr and below in the page there is the example I tried to compile.
But my compiler gives this error: C:\Users\~1\~\ccNPvCtN.o main.cpp:(.text+0x78): undefined reference to `cpr::Parameters::Parameters(std::initializer_list<cpr::Parameter> const&)'
How can I solve this issue ?
Any help will be very appreciated.
Davide
That's a linker error. You need to tell your linker where to find the cpr library.
Helllo Mike....
Thanks for answering me.
It seems me very strange, since I put cpr library in my \include compiler's directory (if I write '#include <cpr/cpr.>', using angular brackets; I get the same, identical error.
Anyway could you suggest me how could tell linker where to find the cpr library ?
Regards,
Davide
closed account (E0p9LyTq)
How to tell the linker where to find the library is dependent on how you compile your program. We need more information:

1. what is your compiler?
2. Do you compile your programs using a command line or make file? An integrated development environment (Visual Studio, for instance)?
Last edited on
It seems me very strange, since I put cpr library in my \include compiler's directory (if I write '#include <cpr/cpr.>', using angular brackets; I get the same, identical error.


#include statements tell the compiler which header files to include (*). They have nothing to do with telling the linker where a library is.

Do you understand the difference between a library, and a header file?

Anyway could you suggest me how could tell linker where to find the cpr library ?

As FurryGuy says, that depends on what compiler and what IDE you're using.

(*) Well, actually, they tell the preprocessor which header files to include, but that distinction doesn't matter right now.
Last edited on
Hello
@MikeyBoy and @FurryGuy
Thanks for helping me.
I use g++ complier and mingw.
The catch it is the first time I use a third part c++ library and I have any idea how to do.
Could give me explanations (or suggest me some online tutorials) how to deploy, use and linking a third part c++ library ?
Advanced thanks.
Topic archived. No new replies allowed.