首页 > 解决方案 > Thrift C++ 链接器错误(增强智能指针)

问题描述

我正在按照简单的 Thrift 教程制作一个简单的部署服务器(在此处找到:https ://wiki.apache.org/thrift/ThriftUsageC%2B%2B/ )。

然而,尽管完全复制了骨架并使用教程进行链接,但我遇到了以下链接器错误,即使在使用-lthriftand与 Thrift 正确链接后也是如此-L/usr/local/lib

gen-cpp/server.o: In function `main':
/home/will/Documents/Research_2018/Thrift-Javascript-to-CPP/server.cpp:56: 
undefined reference to `apache::thrift::server::TSimpleServer::TSimpleServer
(boost::shared_ptr<apache::thrift::TProcessor> const&, 
boost::shared_ptr<apache::thrift::transport::TServerTransport> const&, 
boost::shared_ptr<apache::thrift::transport::TTransportFactory> const&, 
boost::shared_ptr<apache::thrift::protocol::TProtocolFactory> const&)'
collect2: error: ld returned 1 exit status

我已经从最新的 tarball(版本 0.11.0)下载并编译了 Thrift。在比较了我的文件的目标文件的符号表server.o和 Thrift in 的库文件之后/usr/local/lib,看起来好像 Thrift 库使用std::smart_pointer而不是编译boost::smart_pointer,即使在我添加之后

AC_DEFINE([FORCE_BOOST_FUNCTIONAL], [], [Forces boost usage])
AC_DEFINE([FORCE_BOOST_SMART_PTR], [], [Forces boost usage of smart ptrs])

到 Thrift 库的 configure.ac 文件。我的编译器没有内置的 C++11 支持,但它支持带有std=c++11标志的功能。如何解决此链接器错误?

(检查了 Apache Thrift 教程中 C++ 链接器错误中的问题- 未成功更改 thrift 文件后未定义符号和C++ 链接器错误)。

标签: c++thrift

解决方案


@Will Brackenbury

我删除 AX_CXX_COMPILE_STDCXX_11([noext], [optional]),但遇到以下错误

未定义对 `apache::thrift::server::TThreadedServer::TThreadedServer(std::shared_ptr const&, std::shared_ptr const&, std::shared_ptr const&, std::shared_ptr const&, std::shared_ptr const&)' 的引用


推荐阅读