Giter Club home page Giter Club logo

Comments (22)

dwburke avatar dwburke commented on June 6, 2024 3

@kiyology
iirc you want to do

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

from restclient-cpp.

KevinIsSun avatar KevinIsSun commented on June 6, 2024 2

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.

from restclient-cpp.

NibrassHaider avatar NibrassHaider commented on June 6, 2024 1

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

from restclient-cpp.

mrtazz avatar mrtazz commented on June 6, 2024

this looks like a duplicate of #55, closing this in favor of the existing issue. If it's not the same one, please reopen.

from restclient-cpp.

mrtazz avatar mrtazz commented on June 6, 2024

On closer inspection this is most likely not the same issue. Can you provide your platform and environment details and the output log of the failed compilation please?

from restclient-cpp.

msofyanqusyairi avatar msofyanqusyairi commented on June 6, 2024

i have the same problem. i used on raspberry pi

from restclient-cpp.

mrtazz avatar mrtazz commented on June 6, 2024

Did you install it into the default location as root? Have you run /sbin/ldconfig after installation?

from restclient-cpp.

gosantos avatar gosantos commented on June 6, 2024

I am facing a similar issue with this lib. I've got this error:

main.cpp:(.text+0x64): undefined reference to `RestClient::get(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&)'

I have used this link to setup the lib:

https://packagecloud.io/mrtazz/restclient-cpp/packages/ubuntu/trusty/restclient-cpp_0.4.4-1_amd64.deb

G++ and Ubuntu version:
g++ (Ubuntu 5.4.0-6ubuntu1~16.04.2) 5.4.0 20160609

from restclient-cpp.

mrtazz avatar mrtazz commented on June 6, 2024

@gosantos can you provide the test program that throws this error on compilation?

from restclient-cpp.

gosantos avatar gosantos commented on June 6, 2024

@mrtazz I recompiled the lib from source and now I've got the same error:

main.cpp:(.text+0x45): undefined reference to `RestClient::get(std::string const&)'

My code is very simple:

#include "restclient-cpp/restclient.h"

int main(){

  RestClient::Response r = RestClient::get("http://ip.jsontest.com/?callback=showMyIP");

  return 0;
}

from restclient-cpp.

mrtazz avatar mrtazz commented on June 6, 2024

@gosantos thanks! can you also provide the command with which you compiled the test program?

For reference, this is how it's linked on CI where the build works

from restclient-cpp.

gosantos avatar gosantos commented on June 6, 2024

@mrtazz yes, ofc. I am using g++ main.cpp -o main
Btw I have ran the command /sbin/ldconfig and it didn't work as well;

from restclient-cpp.

mrtazz avatar mrtazz commented on June 6, 2024

You have to tell it to link the shared library in as well. Something like g++ main.cpp -o main -I /path/to/restclient-cpp-headers -L /path/to/restclient-cpp-so/ -l librestclient -lcurl

from restclient-cpp.

mrtazz avatar mrtazz commented on June 6, 2024

closing this issue. Please reopen if the problem persists.

from restclient-cpp.

kiyology avatar kiyology commented on June 6, 2024

@mrtazz I'm having this issue too. i used -L /usr/local/include/restclient-cpp/ /usr/local/lib/librestclient-cpp.so /usr/lib/x86_64-linux-gnu/libcurl.a and I'm getting
c++: warning: /usr/local/lib/librestclient-cpp.so: linker input file unused because linking not done c++: warning: /usr/lib/x86_64-linux-gnu/libcurl.a: linker input file unused because linking not done [100%] Linking CXX executable testing CMakeFiles/testing/testing.o: In function main':
/home/xxxxxx/testing.cpp:1088: undefined reference to RestClient::get(std::string const&)' collect2: error: ld returned 1 exit status
Any idea how to solve this? Been debugging all day long. Thanks!

from restclient-cpp.

kiyology avatar kiyology commented on June 6, 2024

@mrtazz Got it working now. Previously failed because of my cmake configuration. Thanks!

from restclient-cpp.

chshaiiith avatar chshaiiith commented on June 6, 2024

Hi @mrtazz, I have been facing with compiling the simple code. I am getting

some.cpp:(.text+0x57): undefined reference to `RestClient::get(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&)'
collect2: error: ld returned 1 exit status

To compile the code I am using : g++ -L /usr/local/lib -lrestclient-cpp -lcurl some.cpp

Also my code looks like :
#include "restclient-cpp/restclient.h"

using namespace std;

int main() {
RestClient::Response r = RestClient::get("http://localhost:8080/get_logs/1/2");
return 0;
}

========================
For installation , I have used

git clone https://github.com/mrtazz/restclient-cpp.git
cd restclient-cpp
./autogen.sh
./configure
make install

Kindly let me know what I did wrong ? Any help would be good ! :)

from restclient-cpp.

mrtazz avatar mrtazz commented on June 6, 2024

do you have the headers in your include path like -I /usr/local/include?

from restclient-cpp.

4rterius avatar 4rterius commented on June 6, 2024

undefined reference to RestClient::get(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'

Tried installing your lib via every method I found, still doesn't work.

Header files included, include path told to the compiler; -L /usr/local/lib/ and -lrestclient-cpp passed to linker, all files ARE in that directory.

ldconfig -p shows that ld sees the library, and ar with objdump show that such symbols are in the file...

Even tried moving the files between usr/lb and usr/local/lib, renaming them with or without the - symbol...
I've been working on it all day, idk what else to do.

Here's what is passed to the compiler:
g++ tests/tests_all.cpp -std=c++1z -pthread -Iinclude/ -Ilibs/ -L /usr/local/lib/ -L../build -o tests/tests_all -lrestclient-cpp -lcurl -lgtest build/libao3.a

from restclient-cpp.

4rterius avatar 4rterius commented on June 6, 2024

Well, sorry for the mess, figured out I should never forget there's no evil magic when working with code.
The problem was on my side, and quite common, I must say, and it was about linking order.

I use GNU Make, and my makefile has the following line:
TEST_LIBRARIES=$(LIBRARIES) $(OUT) -lgtest, where $(OUT) was the static library I made with make build and $(LIBRARIES) == -lrestclient-cpp

I got confused and for some reason didn't realize that not only the executable, but also the library in $(OUT) depended on the restclient lib. Well, I realized, but didn't pay much attention to it. So, it was all about linking order, β„–0 solution on StackExchange. πŸ€¦β€β™‚οΈ

My bad, sorry again.
Your library is awesome πŸ† πŸ‘

from restclient-cpp.

mrtazz avatar mrtazz commented on June 6, 2024

@rakhack Thanks! Glad you found a fix :)

from restclient-cpp.

raaka1 avatar raaka1 commented on June 6, 2024

g++ main.cpp -o main -I /home/raak/restclient-cpp/include/ -L /usr/local/lib/librestclient-cpp.so -lcurl -L /usr/local/lib -lrestclient-cpp

works for me

from restclient-cpp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.