meltwater / served

A C++11 RESTful web server library
MIT License
710 stars 174 forks source link

Issues compiling hello world #73

Open evanugarte opened 3 years ago

evanugarte commented 3 years ago

After running the install steps with cmake from the README's building steps, i am met with the below errors:

/usr/bin/ld: /tmp/ccb5Bytw.o: in function `main::{lambda(served::response&, served::request const&)#1}::operator()(served::response&, served::request const&) const':
main.cpp:(.text+0x76): undefined reference to `served::response::operator<<(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/usr/bin/ld: /tmp/ccb5Bytw.o: in function `main':
main.cpp:(.text+0x11a): undefined reference to `served::multiplexer::multiplexer()'
/usr/bin/ld: main.cpp:(.text+0x192): undefined reference to `served::multiplexer::handle(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
/usr/bin/ld: main.cpp:(.text+0x1b6): undefined reference to `served::methods_handler::get(std::function<void (served::response&, served::request const&)>)'
/usr/bin/ld: main.cpp:(.text+0x2d3): undefined reference to `served::net::server::server(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, served::multiplexer&, bool)'
/usr/bin/ld: main.cpp:(.text+0x328): undefined reference to `served::net::server::run(int, bool)'
/usr/bin/ld: /tmp/ccb5Bytw.o: in function `served::net::server::~server()':
main.cpp:(.text._ZN6served3net6serverD2Ev[_ZN6served3net6serverD5Ev]+0x2e): undefined reference to `served::net::connection_manager::~connection_manager()'
collect2: error: ld returned 1 exit status

seems like it is a linker error? i am compiling with g++ -std=c++11 main.cpp -Iinclude -Iserved/src/served -lboost_system -lpthread from the directory i cloned the served project into.

i will try building with blaze tomorrow to see if this resolves it

dominique120 commented 3 years ago

Dont forget to link against libserved. To have it you must build and install served. Also for some reason my application did not start so I had to do this as well:

ln /usr/local/lib/libserved.so.1.4 /usr/lib64/libserved.so.1.4

MrBeanc commented 3 years ago

I encountered the same problem when compiling. Can you provide us with a standard compilation format。 i am compiling with clang++-9 a.cpp -std=c++11 -lboost_system

dominique120 commented 3 years ago

Dont forget that you must build and install served. Once you have done that you must link against libserved.so.