Comments (12)
Solved... Would anyone else have guessed that -lnet
had to come after the name of the source file? Didn't know that, but I tested a bit and that seems to be the case.
Final command: g++ demo.cpp -lnet -std=c++11 -o demo
Also, for a cmake build, the above command is accomplished by adding target_link_libraries(demo net)
, again AFTER add_executable(demo demo.cpp)
.
from pistache.
Hello,
If you look carefully at the compile error, you'll see that you triggered a static assertion:
/usr/local/include/pistache/http.h:758:5: error: static assertion failed: An http handler must be an http prototype, did you forget the HTTP_PROTOTYPE macro ?
You have to use the HTTP_PROTOTYPE
macro in your Handler:
struct HelloHandler : public Http::Handler {
HTTP_PROTOTYPE(HelloHandler)
void onRequest(const Http::Request& request, Http::ResponseWriter writer) {
writer.send(Http::Code::Ok, "Hello, World!");
}
};
I'll update the README
from pistache.
Thanks, I'm going further but here's the next issue:
gcc -std=c++11 hello.cc
/tmp/ccVAa4xI.o: In function `main':
hello.cc:(.text+0x13d): undefined reference to `Net::Address::Address(char const*)'
/tmp/ccVAa4xI.o: In function `__static_initialization_and_destruction_0(int, int)':
hello.cc:(.text+0x1b8): undefined reference to `std::ios_base::Init::Init()'
hello.cc:(.text+0x1c7): undefined reference to `std::ios_base::Init::~Init()'
/tmp/ccVAa4xI.o: In function `Async::PromiseBase::~PromiseBase()':
hello.cc:(.text._ZN5Async11PromiseBaseD2Ev[_ZN5Async11PromiseBaseD5Ev]+0x29): undefined reference to `operator delete(void*)'
/tmp/ccVAa4xI.o: In function `Async::PromiseBase::~PromiseBase()':
hello.cc:(.text._ZN5Async11PromiseBaseD0Ev[_ZN5Async11PromiseBaseD5Ev]+0x20): undefined reference to `operator delete(void*)'
/tmp/ccVAa4xI.o: In function `Net::Http::Mime::MediaType::MediaType()':
hello.cc:(.text._ZN3Net4Http4Mime9MediaTypeC2Ev[_ZN3Net4Http4Mime9MediaTypeC5Ev]+0x38): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string()'
/tmp/ccVAa4xI.o: In function `Net::Http::Header::Header::~Header()':
hello.cc:(.text._ZN3Net4Http6Header6HeaderD2Ev[_ZN3Net4Http6Header6HeaderD5Ev]+0xd): undefined reference to `vtable for Net::Http::Header::Header'
hello.cc:(.text._ZN3Net4Http6Header6HeaderD2Ev[_ZN3Net4Http6Header6HeaderD5Ev]+0x29): undefined reference to `operator delete(void*)'
/tmp/ccVAa4xI.o: In function `Net::Http::Header::Header::~Header()':
hello.cc:(.text._ZN3Net4Http6Header6HeaderD0Ev[_ZN3Net4Http6Header6HeaderD5Ev]+0x20): undefined reference to `operator delete(void*)'
/tmp/ccVAa4xI.o: In function `Net::Http::Header::Header::Header()':
from pistache.
You should:
1/ Compile with g++
, not gcc
.
2/ Make sure to link with -lnet
from pistache.
I'm certainly missing something, still got errors with g++
g++ -lnet -std=c++11 hello.cc
/tmp/ccxhJsLk.o: In function `main':
hello.cc:(.text+0x13d): undefined reference to `Net::Address::Address(char const*)'
/tmp/ccxhJsLk.o: In function `Net::Http::Header::Header::~Header()':
hello.cc:(.text._ZN3Net4Http6Header6HeaderD2Ev[_ZN3Net4Http6Header6HeaderD5Ev]+0xd): undefined reference to `vtable for Net::Http::Header::Header'
/tmp/ccxhJsLk.o: In function `Net::Http::Header::Header::Header()':
hello.cc:(.text._ZN3Net4Http6Header6HeaderC2Ev[_ZN3Net4Http6Header6HeaderC5Ev]+0x9): undefined reference to `vtable for Net::Http::Header::Header'
/tmp/ccxhJsLk.o: In function `Net::Http::Header::ContentType::ContentType(Net::Http::Mime::MediaType const&)':
hello.cc:(.text._ZN3Net4Http6Header11ContentTypeC2ERKNS0_4Mime9MediaTypeE[_ZN3Net4Http6Header11ContentTypeC5ERKNS0_4Mime9MediaTypeE]+0x1e): undefined reference to `vtable for Net::Http::Header::ContentType'
from pistache.
How did you build and install Pistache ?
from pistache.
I followed this guide: http://pistache.io/quickstart#installing-pistache
from pistache.
I've had the same issue. I had to execute the ldconfig command as root.
from pistache.
Similar errors for me, even after ldconfig. However, the guide to compile the sources also compiles the examples, and there's a working binary of http_server under pistache/build/examples. Some more investigation needed...
from pistache.
same issue as @jeffvandyke running ldconfig
doesn't help
from pistache.
same issue here. ldconfig helps but after executing my binary it throws:
terminate called after throwing an instance of 'std::invalid_argument'
what(): Invalid address
Aborted (core dumped)
any luck?
command to build: sudo g++ test.cpp -o test -std=c++11
UPDATE
Sorry, it's my fault. So I googled the error and I found the reason on StackOverflow: "it means you are giving bad input for what()"
So I look in my code and found out I had a typo at Http::listenAndServe <HelloHandler> ("*:6666");
, which I accidentally wrote Http::listenAndServe <HelloHandler> ("*.6666");
Now my code is running like charm, I'm using ubuntu 16.04 LTS on parallel desktop on my Mbp2013
from pistache.
@jeffvandyke t-h-a-n-k-y-o-u ! Working as expected with -lnet
after the source
from pistache.
Related Issues (20)
- [BUG] ResponseWriter::setCompression() chokes on identity encoding
- [BUG] Fails to fetch build dependencies in autopkgtest HOT 7
- [BUG] All PPA builds failing due to missing zlib headers
- [BUG] New compression code fails to build on armhf HOT 5
- decode uri
- Complete BSD support HOT 4
- "Stack smashing detected" error in ubuntu docker container HOT 17
- New release to conan HOT 1
- keep alive timeout doesn't add to response header
- Pistache very poor performance when POST size exceeds `Endpoint::options().maxRequestSize()`, and `maxRequestSize` is large. HOT 4
- Out of bound read in std::strtol while parsing HTTP requests HOT 4
- Endpoint::Options::backlog_ is not used HOT 2
- What's up with the logging? HOT 3
- [FEATURE REQUEST] Add support for zstd compression
- ci: coverage fails on debian:testing runners HOT 3
- Cant stream MJPEG with multipart/x-mixed-replace HOT 2
- releasing / tagging HOT 1
- Pistacheio support for QNX
- “stack smashing detected” error when processing Get requests via generated-cpp-pistache-server HOT 6
- failed to build example HOT 4
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 pistache.