Comments (22)
@kiyology
iirc you want to do
-L /usr/local/lib -lrestclient-cpp
from restclient-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.
from restclient-cpp.
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 .
from restclient-cpp.
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.
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.
i have the same problem. i used on raspberry pi
from restclient-cpp.
Did you install it into the default location as root? Have you run /sbin/ldconfig
after installation?
from restclient-cpp.
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:
G++ and Ubuntu version:
g++ (Ubuntu 5.4.0-6ubuntu1~16.04.2) 5.4.0 20160609
from restclient-cpp.
@gosantos can you provide the test program that throws this error on compilation?
from restclient-cpp.
@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.
@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.
@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.
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.
closing this issue. Please reopen if the problem persists.
from restclient-cpp.
@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.
@mrtazz Got it working now. Previously failed because of my cmake configuration. Thanks!
from restclient-cpp.
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.
do you have the headers in your include path like -I /usr/local/include
?
from restclient-cpp.
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.
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.
@rakhack Thanks! Glad you found a fix :)
from restclient-cpp.
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)
- Disable SSL peer validation
- How to pass in parameters
- How to deal with this type of dataοΌget method
- valgrind HOT 1
- Basic Post Request isn't working
- Proxy tunnel is enabled on all connections
- Request URL changes if I execute it in different thread
- How to set custom certificate in client? HOT 1
- Support body in delete
- Connection::post() seems to send deformed data
- RestClient::Response reassignment is null
- coud not support the asynchronous non-blocking send? curl_multi_perform
- does it support http2 now? HOT 1
- async get/post function support?
- librestclient-cpp.so HOT 1
- Release 0.5.3
- move release automation to GitHub actions
- Export symbols on Windows when building shared library
- [Gtest Question] What kind of http server used to test?
- void Connection::SetVerifyPeer(bool _verifyPeer) is not usefule to ignore peer verification
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from restclient-cpp.