【发布时间】:2018-08-19 14:43:30
【问题描述】:
我正在按照简单的 Thrift 教程制作一个简单的部署服务器(可在此处找到:https://wiki.apache.org/thrift/ThriftUsageC%2B%2B/)。
但是,尽管完全复制了骨架并使用教程进行链接,但我遇到了以下链接器错误,即使在使用 -lthrift 和 -L/usr/local/lib 正确链接到 Thrift 之后:
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 文件的目标文件的符号表和 /usr/local/lib 中 Thrift 的库文件之后,看起来好像使用 std::smart_pointer 而不是 boost::smart_pointer 编译的 Thrift 库,即使在我添加之后
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 标志的功能。如何解决此链接器错误?
(检查了C++ linker error in Apache Thrift tutorial - undefined symbols 和C++ linker error after change in thrift file 的问题,但没有成功)。
【问题讨论】: