首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >由于链接错误,无法使用Pistache.io构建C++程序

由于链接错误,无法使用Pistache.io构建C++程序
EN

Stack Overflow用户
提问于 2021-07-24 23:16:55
回答 1查看 69关注 0票数 1

我按照官方网站上的说明构建并安装了Pistache.io。现在,我正在尝试从官方存储库构建这个示例程序:https://github.com/pistacheio/pistache/blob/master/examples/hello_server.cc

然而,即使我使用了-lpistache标志,我也得到了以下错误:

代码语言:javascript
运行
复制
g++ -Wall -Wextra -std=c++17  -lpistache  hellopis.cpp   -o hellopis
/usr/bin/ld: /tmp/ccuHXrLC.o: warning: relocation against `_ZTVN8Pistache3Tcp7HandlerE' in read-only section `.text._ZN8Pistache3Tcp7HandlerC2ERKS1_[_ZN8Pistache3Tcp7HandlerC5ERKS1_]'
/usr/bin/ld: /tmp/ccuHXrLC.o: in function `main':
hellopis.cpp:(.text+0x3b): undefined reference to `Pistache::Port::Port(unsigned short)'
/usr/bin/ld: hellopis.cpp:(.text+0x4a): undefined reference to `Pistache::IP::any()'
/usr/bin/ld: hellopis.cpp:(.text+0x9f): undefined reference to `Pistache::Address::Address(Pistache::IP, Pistache::Port)'
/usr/bin/ld: hellopis.cpp:(.text+0xb2): undefined reference to `Pistache::Http::Endpoint::options()'
/usr/bin/ld: hellopis.cpp:(.text+0xc6): undefined reference to `Pistache::Http::Endpoint::Options::threads(int)'
/usr/bin/ld: hellopis.cpp:(.text+0x103): undefined reference to `Pistache::Http::Endpoint::Endpoint(Pistache::Address const&)'
/usr/bin/ld: hellopis.cpp:(.text+0x11c): undefined reference to `Pistache::Http::Endpoint::init(Pistache::Http::Endpoint::Options const&)'
/usr/bin/ld: hellopis.cpp:(.text+0x151): undefined reference to `Pistache::Http::Endpoint::setHandler(std::shared_ptr<Pistache::Http::Handler> const&)'
/usr/bin/ld: hellopis.cpp:(.text+0x178): undefined reference to `Pistache::Http::Endpoint::serve()'
/usr/bin/ld: /tmp/ccuHXrLC.o: in function `Pistache::Http::Endpoint::~Endpoint()':
hellopis.cpp:(.text._ZN8Pistache4Http8EndpointD2Ev[_ZN8Pistache4Http8EndpointD5Ev]+0x3c): undefined reference to `Pistache::Tcp::Listener::~Listener()'
/usr/bin/ld: /tmp/ccuHXrLC.o: in function `Pistache::Async::Promise<long> Pistache::Http::ResponseWriter::send<13ul>(Pistache::Http::Code, char const (&) [13ul], Pistache::Http::Mime::MediaType const&)':
hellopis.cpp:(.text._ZN8Pistache4Http14ResponseWriter4sendILm13EEENS_5Async7PromiseIlEENS0_4CodeERAT__KcRKNS0_4Mime9MediaTypeE[_ZN8Pistache4Http14ResponseWriter4sendILm13EEENS_5Async7PromiseIlEENS0_4CodeERAT__KcRKNS0_4Mime9MediaTypeE]+0x3b): undefined reference to `Pistache::Http::ResponseWriter::sendImpl(Pistache::Http::Code, char const*, unsigned long, Pistache::Http::Mime::MediaType const&)'
/usr/bin/ld: /tmp/ccuHXrLC.o: in function `Pistache::Tcp::Handler::Handler(Pistache::Tcp::Handler const&)':
hellopis.cpp:(.text._ZN8Pistache3Tcp7HandlerC2ERKS1_[_ZN8Pistache3Tcp7HandlerC5ERKS1_]+0x26): undefined reference to `vtable for Pistache::Tcp::Handler'
/usr/bin/ld: /tmp/ccuHXrLC.o: in function `Pistache::Http::Handler::Handler(Pistache::Http::Handler const&)':
hellopis.cpp:(.text._ZN8Pistache4Http7HandlerC2ERKS1_[_ZN8Pistache4Http7HandlerC5ERKS1_]+0x26): undefined reference to `vtable for Pistache::Http::Handler'
/usr/bin/ld: /tmp/ccuHXrLC.o: in function `Pistache::Http::Handler::~Handler()':
hellopis.cpp:(.text._ZN8Pistache4Http7HandlerD2Ev[_ZN8Pistache4Http7HandlerD5Ev]+0xf): undefined reference to `vtable for Pistache::Http::Handler'
/usr/bin/ld: hellopis.cpp:(.text._ZN8Pistache4Http7HandlerD2Ev[_ZN8Pistache4Http7HandlerD5Ev]+0x22): undefined reference to `Pistache::Tcp::Handler::~Handler()'
/usr/bin/ld: /tmp/ccuHXrLC.o: in function `Pistache::Http::Handler::Handler()':
hellopis.cpp:(.text._ZN8Pistache4Http7HandlerC2Ev[_ZN8Pistache4Http7HandlerC5Ev]+0x15): undefined reference to `Pistache::Tcp::Handler::Handler()'
/usr/bin/ld: hellopis.cpp:(.text._ZN8Pistache4Http7HandlerC2Ev[_ZN8Pistache4Http7HandlerC5Ev]+0x1c): undefined reference to `vtable for Pistache::Http::Handler'
/usr/bin/ld: hellopis.cpp:(.text._ZN8Pistache4Http7HandlerC2Ev[_ZN8Pistache4Http7HandlerC5Ev]+0x7b): undefined reference to `Pistache::Tcp::Handler::~Handler()'
/usr/bin/ld: /tmp/ccuHXrLC.o:(.data.rel.ro._ZTV12HelloHandler[_ZTV12HelloHandler]+0x28): undefined reference to `Pistache::Http::Handler::onInput(char const*, unsigned long, std::shared_ptr<Pistache::Tcp::Peer> const&)'
/usr/bin/ld: /tmp/ccuHXrLC.o:(.data.rel.ro._ZTV12HelloHandler[_ZTV12HelloHandler]+0x30): undefined reference to `Pistache::Http::Handler::onConnection(std::shared_ptr<Pistache::Tcp::Peer> const&)'
/usr/bin/ld: /tmp/ccuHXrLC.o:(.data.rel.ro._ZTV12HelloHandler[_ZTV12HelloHandler]+0x38): undefined reference to `Pistache::Tcp::Handler::onDisconnection(std::shared_ptr<Pistache::Tcp::Peer> const&)'
/usr/bin/ld: /tmp/ccuHXrLC.o:(.data.rel.ro._ZTV12HelloHandler[_ZTV12HelloHandler]+0x48): undefined reference to `Pistache::Http::Handler::onTimeout(Pistache::Http::Request const&, Pistache::Http::ResponseWriter)'
/usr/bin/ld: /tmp/ccuHXrLC.o:(.data.rel.ro._ZTI12HelloHandler[_ZTI12HelloHandler]+0x10): undefined reference to `typeinfo for Pistache::Http::Handler'
/usr/bin/ld: warning: creating DT_TEXTREL in a PIE
collect2: error: ld returned 1 exit status
make: *** [<builtin>: hellopis] Error 1

这个错误是什么?我如何解决它?

EN

回答 1

Stack Overflow用户

发布于 2021-07-25 00:12:32

当我在不使用Makefile的情况下自己调用g++命令时,这个问题就解决了。特别是,我运行了以下命令:g++ -Wall -Wextra -std=c++17 hellopis.cpp -o hellopis -lpistache

我的Makefile如下:

代码语言:javascript
运行
复制
CXXFLAGS=-Wall -Wextra -std=c++17
LDFLAGS=-lpistache
票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68511307

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档