nvcc 和 BOOST 库编译错误
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 不兼容,还是我的代码有问题?
nvcc throws
/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
the has_constraints.hpp already has some suspicious code in it:
#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
Question: Is this a nvcc - boost incompatibility, or could there be something wrong with my code?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
为什么有“&”在“模型::约束”之前?我认为这就是问题所在。 (//显然不是)
编辑:
http://forums.nvidia.com/index.php php?showtopic=182890 讨论这个问题并解决一些问题
http://forums.nvidia.com/index.php?showtopic=150025
编辑2:
好吧,在围绕这个问题运行了一段时间之后,这就是我坚持的:
http://forums.nvidia.com/index.php?showtopic=215470 “那里是 boost 和 nvcc 的一个已知兼容性问题。解决方法是拆分源代码,以便使用 nvcc 编译 cuda 代码,并使用主机编译器编译 boost 代码。”作者:Justin Luitjens,在小组:NVIDIA 员工
尝试一下,但如果无法使其工作,请单独编译,然后链接它们。
Why do you have the "&" before "Model::constraints"? I would think that's the problem. (// it's not apparently)
EDIT:
http://forums.nvidia.com/index.php?showtopic=182890 talk about this issue and have some hack work arounds
http://forums.nvidia.com/index.php?showtopic=150025
EDIT2:
Well, after running around this for a while, this is what I'm sticking with:
http://forums.nvidia.com/index.php?showtopic=215470 "There is a known compatibility issue with boost and nvcc. A work around is to split the sources such that you compile the cuda code with nvcc and the boost code with the host compiler." by Justin Luitjens in the Group: NVIDIA Employees
Try it out, but if you can't make it work, compile separately, and then link them.
我这里有一个补丁 http://code.google.com/p/asadchev/source/browse/trunk/projects/boost/boost-1.46.0.nvcc.patch
也许你可以看到什么同样更改并修复您的代码
请注意,类似 gcc 和类似 Egg 的编译器部分都可以看到源代码。
I have a patch here http://code.google.com/p/asadchev/source/browse/trunk/projects/boost/boost-1.46.0.nvcc.patch
Perhaps you can see what is changed and fix your code likewise
Be aware that the source is seen by both, gcc-like and egg-like compiler parts.
我们最后所做的是关闭 has_constraints_ ,如 Sun Studio 11 问题中引用的示例所示
What we did at the end was to turn has_constraints_ off as in the example quoted in the question for Sun Studio 11