restclient-cpp: Undefined reference to `RestClient::get(std::string const&)'

Hello,

So I installed all the files using the configure, make and make install commands. Now when I use the example I get the following error: Undefined reference to RestClient::get(std::string const&). Do you have any idea how to fix this?

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 22 (9 by maintainers)

Most upvoted comments

@kiyology iirc you want to do

-L /usr/local/lib -lrestclient-cpp

Sorry, I still get this error. And I have tried all methods mentioned above.

I install this lib by download deb file in https://packagecloud.io/mrtazz/restclient-cpp, and use sudo dpkg -i xxx.deb to install.

After install, i found header files in /usr/include, and so file in /usr/lib/. Then I run sudo ldconfig. my code:

#include "restclient-cpp/restclient.h"
#include <iostream>
#include <string>

int main() {
    std::string url = "http://baidu.com";
    RestClient::Response r = RestClient::get(url);

    std::cout << r.code << "\n";
    return 0;
}

I run g++ -I /usr/include/ -L /usr/lib/ -lrestclient-cpp -lcurl test_restclient.cc to compile. Then I get error message:

/tmp/ccCejkeS.o: In function `main':
test_restclient.cc:(.text+0x66): undefined reference to `RestClient::get(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'

I have no idea how to fix it. It make me so sad.

Anyone can help me for the following problema please build/Debug/Cygwin-Windows/main.o: In function MinHeap<std::string>::insert(int, std::string)': /cygdrive/c/Users/nibrass/Documents/NetBeansProjects/P3_Ex1/MinHeap.h:85: undefined reference to NodeMinHeapstd::string::NodeMinHeap(NodeMinHeapstd::string const&)’ when i click on the error , it takes me to my class MinHeap in a method insert where i creat a node type of NodeMinHeap i don’t know where i am getting wrong, please help me . image