Comments (10)
Please try the following
g++ -std=c++11 -g -I"/usr/local/lib/restbed/distribution/include" example.cpp -o example -L"/usr/local/lib/restbed/distribution/library" -lrestbed
G++ linking options
from restbed.
Hi glederrey,
#include </usr/local/lib/restbed/build/librestbed.so>
Is not a vaild means of linking a library with a C/C++ based compiler. Before proceeding any further would you please provide us with the output of the following command.
g++ --version
from restbed.
Hi,
Okay.. I knew that I was doing something wrong..
Here is the output of the command g++ --version
:
g++ (Ubuntu 4.9.2-0ubuntu1~14.04) 4.9.2 Copyright (C) 2014 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
from restbed.
Hi,
I'm a little bit closer now.. I now use a makefile to link the library. Here it is:
ifndef RESTBED_MODULES_PATH
export RESTBED_MODULES_PATH=/usr/local/lib/restbed
endif
INCLUDE = -I"$(RESTBED_MODULES_PATH)/distribution/include"
LIBRARIES = -L"$(RESTBED_MODULES_PATH)/distribution"
CC=gcc
CXX=g++ -Wno-unused-result -std=c++11
RM=rm -f
CPPFLAGS=-c -Wall
LDFLAGS=-g $(INCLUDE)
LDLIBS=$(LIBRARIES)
SOURCES=example.cpp
OBJECTS=$(SOURCES:.cpp=.o)
EXECUTABLE=example
all: $(SOURCES) $(EXECUTABLE)
$(EXECUTABLE): $(OBJECTS)
$(CXX) $(LDFLAGS) $(OBJECTS) -o $@ $(LDLIBS)
.cpp.o:
$(CXX) $(LDFLAGS) $(CPPFLAGS) $< -o $@ $(LDLIBS)
clean:
$(RM) $(OBJECTS) $(EXECUTABLE)
And if I compile using the command make
, I have this error:
g++ -Wno-unused-result -std=c++11 -g -I"/usr/local/lib/restbed/distribution/include" -c -Wall example.cpp -o example.o -L"/usr/local/lib/restbed/distribution"
g++ -Wno-unused-result -std=c++11 -g -I"/usr/local/lib/restbed/distribution/include" example.o -o example -L"/usr/local/lib/restbed/distribution"
example.o: In function `operator()':
/home/gael/Desktop/restbed-test/example.cpp:20: undefined reference to `restbed::Session::close(int, std::string const&, std::multimap<std::string, std::string, std::less<std::string>, std::allocator<std::pair<std::string const, std::string> > > const&)'
example.o: In function `get_method_handler(std::shared_ptr<restbed::Session> const&)':
/home/gael/Desktop/restbed-test/example.cpp:10: undefined reference to `restbed::Session::get_request() const'
/home/gael/Desktop/restbed-test/example.cpp:13: undefined reference to `restbed::Request::get_header(std::string const&, unsigned long&, unsigned long) const'
/home/gael/Desktop/restbed-test/example.cpp:21: undefined reference to `restbed::Session::fetch(unsigned long, std::function<void (std::shared_ptr<restbed::Session> const&, std::vector<unsigned char, std::allocator<unsigned char> > const&)> const&)'
example.o: In function `main':
/home/gael/Desktop/restbed-test/example.cpp:27: undefined reference to `restbed::Resource::set_path(std::string const&)'
/home/gael/Desktop/restbed-test/example.cpp:28: undefined reference to `restbed::Resource::set_method_handler(std::string const&, std::function<void (std::shared_ptr<restbed::Session> const&)> const&)'
/home/gael/Desktop/restbed-test/example.cpp:31: undefined reference to `restbed::Settings::set_port(unsigned short)'
/home/gael/Desktop/restbed-test/example.cpp:32: undefined reference to `restbed::Settings::set_default_header(std::string const&, std::string const&)'
/home/gael/Desktop/restbed-test/example.cpp:34: undefined reference to `restbed::Service::Service()'
/home/gael/Desktop/restbed-test/example.cpp:35: undefined reference to `restbed::Service::publish(std::shared_ptr<restbed::Resource const> const&)'
/home/gael/Desktop/restbed-test/example.cpp:36: undefined reference to `restbed::Service::start(std::shared_ptr<restbed::Settings const> const&)'
/home/gael/Desktop/restbed-test/example.cpp:34: undefined reference to `restbed::Service::~Service()'
/home/gael/Desktop/restbed-test/example.cpp:34: undefined reference to `restbed::Service::~Service()'
example.o: In function `_ZN9__gnu_cxx13new_allocatorIN7restbed8ResourceEE9constructIS2_IEEEvPT_DpOT0_':
/usr/include/c++/4.9/ext/new_allocator.h:120: undefined reference to `restbed::Resource::Resource()'
example.o: In function `_ZN9__gnu_cxx13new_allocatorIN7restbed8SettingsEE9constructIS2_IEEEvPT_DpOT0_':
/usr/include/c++/4.9/ext/new_allocator.h:120: undefined reference to `restbed::Settings::Settings()'
collect2: error: ld returned 1 exit status
make: *** [example] Error 1
from restbed.
Hi,
I just changed a little bit the makefile like this:
ifndef RESTBED_MODULES_PATH
export RESTBED_MODULES_PATH=/usr/local/lib/restbed
endif
INCLUDE = -I"$(RESTBED_MODULES_PATH)/distribution/include/"
LIBRARIES = -L"$(RESTBED_MODULES_PATH)/distribution/library" -lrestbed
CC=gcc
CXX=g++ -Wno-unused-result -std=c++11
RM=rm -f
CPPFLAGS=-c -Wall
LDFLAGS=-g $(INCLUDE)
LDLIBS=-g $(LIBRARIES)
SOURCES=example.cpp
OBJECTS=$(SOURCES:.cpp=.o)
EXECUTABLE=example
all: $(SOURCES) $(EXECUTABLE)
$(EXECUTABLE): $(OBJECTS)
$(CXX) $(LDFLAGS) $(OBJECTS) -o $@ $(LDLIBS)
.cpp.o:
$(CXX) $(LDFLAGS) $(CPPFLAGS) $< -o $@ $(LDLIBS)
clean:
$(RM) $(OBJECTS) $(EXECUTABLE)
And it compile now.. But I still have a problem when I try to run the program:
gael@mint-gael ~/Desktop/restbed-test $ ./example
./example: error while loading shared libraries: librestbed.so: cannot open shared object file: No such file or directory
If I try your command, it says:
g++: error: example.o: No such file or directory
from restbed.
Please set-up your Linux environment with:
LD_LIBRARY_PATH="/usr/local/lib/restbed/distribution/library"
from restbed.
It worked!! Thank you so much!!
If I can suggest you something, it would be really great if you can add an example of a Makefile or the command to compile your library.. It would prevent having some issues like mine.. =)
Thanks a lot again..
from restbed.
Will look into creating a template.
We love hearing how people are using Restbed. What awesome project are you building?
from restbed.
I'm working for a company called nViso.. We work on analysing faces to detect emotions.. If you want more information, you can take a look at our website: http://nviso.ch/.. And we're using restbed because we have a REST API for our product..
Thanks again for your help..
I give you my Makefile if you want to start with this:
### WARNING: If librestbed.so cannot be found, use the foloowing command:
###
### export LD_LIBRARY_PATH=/usr/local/lib/restbed/distribution/library
###
ifndef RESTBED_MODULES_PATH
export RESTBED_MODULES_PATH=/usr/local/lib/restbed
endif
INCLUDE = -I"$(RESTBED_MODULES_PATH)/distribution/include/"
LIBRARIES = -L"$(RESTBED_MODULES_PATH)/distribution/library" -lrestbed
CC=gcc
CXX=g++ -Wno-unused-result -std=c++11 -fuse-ld=bfd
RM=rm -f
CPPFLAGS=-c -Wall
LDFLAGS=-g $(INCLUDE)
LDLIBS=$(LIBRARIES)
SOURCES=example.cpp
OBJECTS=$(SOURCES:.cpp=.o)
EXECUTABLE=example
all: $(SOURCES) $(EXECUTABLE)
$(EXECUTABLE): $(OBJECTS)
$(CXX) $(LDFLAGS) $(OBJECTS) -o $@ $(LDLIBS)
.cpp.o:
$(CXX) $(LDFLAGS) $(CPPFLAGS) $< -o $@ $(LDLIBS)
clean:
$(RM) $(OBJECTS) $(EXECUTABLE)
from restbed.
Exciting stuff, we wish you all the best. If you require any further help don't hesitate to contact the team.
from restbed.
Related Issues (20)
- Builds with Restbed lib fail, with missing OpenSSL symbols galore HOT 6
- include `pkgconfig` as part of build
- Is there a way to start the server with a non-blocking call and continue working on the same thread? HOT 1
- Why is the CMake config putting "std=gnu++14" in Clang invocations? HOT 4
- http client read timeout results in nothing HOT 1
- The size of the body may cause problems HOT 2
- Suspected memory leak HOT 1
- MINSIGSTKSZ error during building HOT 2
- Cannot buid a static Windows restbed library without export any symbol
- Example/HTTPS_SERVICE error
- Only one handler works in example/RESOURCE_FILTERING. HOT 1
- ask for help:: How to send the main body content multiple times? HOT 1
- CMakeList.txt typos for ssl
- Any idea how I can use restbed in c++ to make PayPal payments using their REST API?
- SSL/TLS: Renegotiation DoS Vulnerability (CVE-2011-1473, CVE-2011-5094)
- Linking with external Asio does not work
- Wrong project version in CMakeLists.txt for tag 4.8
- Permissive LIcense ? HOT 1
- http client post method HOT 1
- Segmentation Fault HOT 1
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 restbed.