I'm trying to build a stand-alone binary containing a Rest API made with pistache framework. For that purpose I created a docker image using "FROM i386/ubuntu:16.04" and installing all dependencies in it. But the binary throws "Segmentation fault" error when I try to execute it and it's compilation shows some warnings.
I compile it with this command (output warnings included):
g++ server.cpp -std=c++11 -lpistache -lssl -lcrypto -pthread -ldl -static -o server
root@91cb986a4e48:/workspace# g++ server.cpp -std=c++11 -lpistache -lssl -lcrypto -pthread -ldl -static -o server
/usr/lib/gcc/i686-linux-gnu/5/../../../i386-linux-gnu/libcrypto.a(dso_dlfcn.o): In function `dlfcn_globallookup':
(.text+0xa): warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
//usr/local/lib/libpistache.a(listener.cc.o): In function `Pistache::Tcp::Listener::bind(Pistache::Address const&)':
listener.cc:(.text+0x1b94): warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
//usr/local/lib/libpistache.a(net.cc.o): In function `Pistache::Address::init(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
net.cc:(.text+0x14ce): warning: Using 'gethostbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
server.cpp contains the hello world code from pistache:
#include <pistache/endpoint.h>
using namespace Pistache;
struct HelloHandler : public Http::Handler {
HTTP_PROTOTYPE(HelloHandler)
void onRequest(const Http::Request&, Http::ResponseWriter writer) override{
writer.send(Http::Code::Ok, "Hello, World!");
}
};
int main() {
Http::listenAndServe<HelloHandler>("*:9080");
}
When I compile and run it in my pc there is no problem (compiling with "g++ server.cpp -std=c++11 -lpistache -o server"), but how can I make it work in my i686 board?
Aucun commentaire:
Enregistrer un commentaire