由于多次重新定义错误,CUDA示例无法编译 [英] CUDA samples not compiling due to multiple redefinition errors

查看:129
本文介绍了由于多次重新定义错误,CUDA示例无法编译的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚在OSX 10.11上使用Xcode 7安装了CUDA工具包7.5.装有GeForce GT 750M的Macbook Pro

I just installed CUDA toolkit 7.5 on OSX 10.11 with Xcode 7. Macbook Pro with GeForce GT 750M

编译(制作)样本时,出现多个重新定义错误.这是前两个:

When compiling (make) the samples I get multiple redefinition errors. Here are the first two:

实际控制台输出(部分)

错误样本:

在tmpxft_0000b964_00000000-19_asyncAPI.compute_20.cudafe1.stub.c:1中包含的文件中: 在/var/folders/bm/fp5n2kzd419c4mbnsmyqf1cm0000gn/T/tmpxft_0000b964_00000000-19_asyncAPI.compute_20.cudafe1.stub.c:7中包含的文件中:7: 在/Developer/NVIDIA/CUDA-7.5/bin/../include/crt/host_runtime.h:247中包含的文件中: 在/Developer/NVIDIA/CUDA-7.5/bin/../include/common_functions.h:224中包含的文件中: 在/Developer/NVIDIA/CUDA-7.5/bin/../include/math_functions.h:10219中包含的文件中: 在/Developer/NVIDIA/CUDA-7.5/bin/../include/math_functions.hpp:1664中包含的文件中: /usr/include/math.h:204:48:错误:重新定义了' inline_isfinitef' 内联__attribute ((< always_inline ))int inline_isfinitef(float __x){ ^ /usr/include/math.h:204:58:注意:以前的定义在这里 extern"C" {__attribute((__ always_inline ))内联int __inline_isfinitef(float __x)

In file included from tmpxft_0000b964_00000000-19_asyncAPI.compute_20.cudafe1.stub.c:1: In file included from /var/folders/bm/fp5n2kzd419c4mbnsmyqf1cm0000gn/T/tmpxft_0000b964_00000000-19_asyncAPI.compute_20.cudafe1.stub.c:7: In file included from /Developer/NVIDIA/CUDA-7.5/bin/../include/crt/host_runtime.h:247: In file included from /Developer/NVIDIA/CUDA-7.5/bin/../include/common_functions.h:224: In file included from /Developer/NVIDIA/CUDA-7.5/bin/../include/math_functions.h:10219: In file included from /Developer/NVIDIA/CUDA-7.5/bin/../include/math_functions.hpp:1664: /usr/include/math.h:204:48: error: redefinition of 'inline_isfinitef' inline __attribute ((always_inline)) int inline_isfinitef(float __x) { ^ /usr/include/math.h:204:58: note: previous definition is here extern "C" { __attribute((__always_inline)) inline int __inline_isfinitef(float __x)

错误与math.h包含有关.有趣的是,如果手动编译某些示例,例如deviceQuery示例,则会进行编译和运行.

The errors are related to math.h includes. Interestingly some of the samples if compiled manually such as the deviceQuery sample do compile and run.

我编写的自定义代码也因相同的错误而失败.在我的代码中,如果我注释掉"math.h",则包含错误是相同的.我确实包括NVIDIA的cutil_math.h

Custom code that I have written also fails with the same errors. In my code if I comment out the "math.h" and the include the errors are the same. I do include NVIDIA's cutil_math.h

我尝试将clang版本降低到6.4,但这没什么区别.我还尝试了多个编译器标志,但无济于事.

I've tried changing the clang version down to 6.4 but it makes no difference. I've also tried multiple compiler flags to no avail.

推荐答案

我提供了可以解决此问题的解决方案,但将来可能会引起问题.

I provide a solution that will fix the problem, but might cause a problem in the future.

错误显示了包含问题的顺序,直到发生问题为止.在这种情况下7.5/bin/../include/math_functions.hpp:1664

The error is showing the sequence of includes down to where the problem is occuring. In this case 7.5/bin/../include/math_functions.hpp:1664

在math_functions.hpp的第1664行上,注释掉其下方的#include "math.h"#include <cmath>.这将删除重新定义,您的项目将不再有此错误,并且示例将编译.

On line 1664 of math_functions.hpp comment out #include "math.h" and #include <cmath> below it. This will remove the redefinition and your project will no longer have this error, and the samples will compile.

这篇关于由于多次重新定义错误,CUDA示例无法编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆