【发布时间】:2016-01-05 03:22:28
【问题描述】:
我已经编译了两个 Boost 库版本 - 1.54 和 1.58 类似:
$ mkdir build && ./bootstrap --prefix=$(pwd)/build
$ ./b2 cxxflags="-stdlib=libstdc++" linkflags="-stdlib=libstdc++" && ./b2 install
现在,我正在尝试编译这个小应用程序:
#include <boost/asio.hpp>
#include <boost/asio/steady_timer.hpp>
boost::asio::io_service io_service_;
boost::asio::steady_timer timer_(io_service_);
int
main ()
{
return 0;
}
像这样: $ g++ -c -std=gnu++11 -stdlib=libstdc++ -I main.cpp
它为 Boost 1.54.0 编译完美,并为 Boost 1.58.0 提供错误(超过 20 个):
boost_1_58_0/build/include/boost/asio/detail/addressof.hpp:31:12: error: no member named 'addressof' in namespace 'std'
using std::addressof;
boost_1_58_0/build/include/boost/asio/detail/handler_alloc_helpers.hpp:37:56: error: no member named 'addressof' in namespace 'boost::asio::detail'
return asio_handler_allocate(s, boost::asio::detail::addressof(h));
~~~~~~~~~~~~~~~~~~~~~^
boost_1_58_0/build/include/boost/asio/detail/handler_alloc_helpers.hpp:48:54: error: no member named 'addressof' in namespace 'boost::asio::detail'
asio_handler_deallocate(p, s, boost::asio::detail::addressof(h));
...
我猜,这是 OS X 特有的,与我传递的 -std 和 -stdlib 标志有关,因为如果我提供其中一个但不是同时提供两个标志,它就会编译。我已经阅读了很多关于 libc++ 和 libstdc++ 的内容,但我需要这些标志,因为我的真实代码(可能已经猜到这只是一个演示代码)需要这些标志才能编译,例如我必须使用 libstdc++ 而不是 libc++,而且我需要 C++11。
对于如何在不放弃这些编译器标志的情况下使用最新的 boost 库有什么建议吗?
【问题讨论】:
标签: c++ c++11 boost libstdc++ libc++