nvcc和BOOST库的编译错误

compilation error with nvcc and BOOST library

本文关键字:编译 错误 BOOST nvcc      更新时间:2023-10-16

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 - boost不兼容,还是我的代码有问题?

为什么在"Model::constraints"之前有"&" ?我认为这就是问题所在。(//不明显)

编辑:

http://forums.nvidia.com/index.php?showtopic=182890讨论这个问题,并有一些hack工作围绕

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

EDIT2:

好吧,经过一段时间的运行,这是我坚持的:

http://forums.nvidia.com/index.php?showtopic=215470 " boost和nvcc存在已知的兼容性问题。一种解决办法是分割源代码,这样你就可以用nvcc编译cuda代码,用主机编译器编译boost代码。"

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

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

也许你可以看到什么改变了,并修复你的代码同样

请注意,源代码可以同时被gcc和egg编译器看到。

最后我们关闭了has_constraints_就像Sun Studio 11问题中引用的例子