编译错误nvcc和BOOST库

时间:2011-12-16 15:55:18

标签: c++ boost cuda nvcc

nvcc抛出

/usr/include/boost/concept/detail/has_constraints.hpp:29: error: ‘&’ cannot appear in a constant-expression
/usr/include/boost/concept/detail/has_constraints.hpp:29: error: template argument 2 is invalid

has_constraints.hpp中已经有一些可疑代码:

#if BOOST_WORKAROUND(__SUNPRO_CC, <= 0x580)
  // Work around the following bogus error in Sun Studio 11, by
  // turning off the has_constraints function entirely:
  //    Error: complex expression not allowed in dependent template
  //    argument expression
  inline no has_constraints_(...);
#else
  template <class Model>
  inline yes has_constraints_(Model*, wrap_constraints<Model,&Model::constraints>* = 0);
  inline no has_constraints_(...);
#endif

问题:这是一个nvcc提升不兼容还是我的代码可能有问题?

3 个答案:

答案 0 :(得分:1)

为什么你有“&amp;”在“模型::约束”之前?我认为这就是问题所在。 (//显然不是这样)

编辑:

http://forums.nvidia.com/index.php?showtopic=182890谈论这个问题并进行一些黑客攻击

http://forums.nvidia.com/index.php?showtopic=150025

EDIT2:

好吧,经过一段时间的努力,这就是我坚持的:

http://forums.nvidia.com/index.php?showtopic=215470“与boost和nvcc存在已知的兼容性问题。解决方法是拆分源代码,以便使用nvcc编译cuda代码,使用主机编译器编译boost代码。”作者:Justin Luitjens在集团:NVIDIA员工

尝试一下,但是如果你不能使它工作,请单独编译,然后链接它们。

答案 1 :(得分:1)

我在这里有一个补丁http://code.google.com/p/asadchev/source/browse/trunk/projects/boost/boost-1.46.0.nvcc.patch

也许您可以看到更改内容并同样修复您的代码

请注意,gcc-like和egg-like编译器部分都可以看到源代码。

答案 2 :(得分:0)

我们最后做的是关闭has_constraints_,就像在Sun Studio 11的问题中引用的示例一样