c++ - 在 Xcode 中使用 boost 库编译项目时出错

标签 c++ xcode boost

我正在使用通过自制软件安装的 boost,并添加“usr/local/include”来搜索 header 路径,添加“usr/local/lib”来搜索库路径。它包含的很好,但我在编译时遇到以下错误:

/usr/local/include/boost/move/unique_ptr.hpp:549:16: Unknown type name 'BOOST_RV_REF_BEG_IF_CXX11'

/usr/local/include/boost/move/unique_ptr.hpp:549:42: 'unique_ptr' cannot be the name of a parameter

/usr/local/include/boost/move/unique_ptr.hpp:549:59: Expected ')'

/usr/local/include/boost/move/unique_ptr.hpp:552:16: Use of undeclared identifier 'u'

这些是 boost 代码中有问题的行:

   template <class U, class E>
   unique_ptr( BOOST_RV_REF_BEG_IF_CXX11 unique_ptr<U, E> BOOST_RV_REF_END_IF_CXX11 u
      BOOST_MOVE_DOCIGN(BOOST_MOVE_I typename bmupd::enable_up_moveconv_constr<T BOOST_MOVE_I D BOOST_MOVE_I U BOOST_MOVE_I E>::type* =0)
      ) BOOST_NOEXCEPT
      : m_data(u.release(), ::boost::move_if_not_lvalue_reference<E>(u.get_deleter()))
   {
      //If T is not an array type, U derives from T
      //it uses the default deleter and T has no virtual destructor, then you have a problem
      BOOST_STATIC_ASSERT(( !::boost::move_upmu::missing_virtual_destructor
                            <D, typename unique_ptr<U, E>::pointer>::value ));
   }

最佳答案

我收到此错误的原因是因为我在 xcode 中将/usr/local/include 添加到“Header Search Paths”而不是“User Header Search Paths”中。不知道为什么会导致此错误,可能没有包含某些内容,但将其添加到两者中都已修复。

enter image description here

为了让 boost 充分发挥作用,我还必须将 .dylib(来自/usr/local/lib)添加到 Build Phases 中的“Link Binary With Libaries”。

enter image description here

关于c++ - 在 Xcode 中使用 boost 库编译项目时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37511942/

相关文章:

c++ - 函数体中的命名空间前缀

c++ - feof() 未达到 EOF 时返回 true

ios - 尝试运行 Unity3D 应用程序时出现 XCode 错误

ios - 如何修复 iOS 模拟器旋转?

c++ - 是否可以将 Boost uint128_t 数据类型存储到原始 int 中?

python - Windows VS 中的 Boost numpy 链接器错误

c++ - 丢失的一元 std::copy 的最佳实现

ios - 核心数据缓慢获取关系对象

c++ - 使用 MSVC 2015 构建 boost 1.55 时指定工具集版本

c++ - 强制页面边界段错误?