VS2005 + CUDA4.0 环境下 出现math_functions.h编译 error

请教大家下述问题如何解决:
我的环境 VS2005 + CUDA4.0 32bit , 在正确配置完成的情况下,我编译了一个简单的例子,出现了如下系统错误:

1>------ 已启动生成: 项目: CUDAWinApp1, 配置: Debug Win32 ------
1>Compiling with CUDA Build Rule…
1>“C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.0\bin\nvcc.exe” -arch sm_13 -ccbin “d:\Microsoft Visual Studio 8\VC\bin” -Xcompiler “/EHsc /W3 /nologo /Od /Zi /RTC1 /MTd " -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.0\include” -I"D:\NVIDIA Corporation\NVIDIA GPU Computing SDK 4.0\C\common\inc" -maxrregcount=32 --compile -o “Debug\sample.cu.obj” “e:\CUDAWinApp1\CUDAWinApp1\sample.cu”
1>sample.cu
1>c:\program files\nvidia gpu computing toolkit\cuda\v4.0\include\math_functions.h(643): error: function “abs(long long)” has already been defined
1>c:\program files\nvidia gpu computing toolkit\cuda\v4.0\include\math_functions.h(795): error: function “hypot(float, float)” has already been defined
1>2 errors detected in the compilation of “C:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/tmpxft_00000790_00000000-6_sample.cpp1.ii”.
1>Project : error PRJ0019: 工具从"Compiling with CUDA Build Rule…"
1>生成日志保存在“file://e:\CUDAWinApp1\CUDAWinApp1\Debug\BuildLog.htm”

最后更换为VS2008后,上述错误自动消失。但我在CUDA4.0 SDK中,发现其明确支持VS2005,请教上述错误如何修正?谢谢!

不include可以使用嗎?

math_functions.h不可能绕过去。毕竟大家都冲着高性能而来,数学函数用的是频繁的。

你要貼上你的code
讓別人來跑跑看嗎?

你重复定义了。。。:frowning:

你转到定义,或者查找下看看。:slight_smile:

我看了,最终确定为VS2005的版本问题。

呵呵,很无语呀,:3_42:

直接采用了赵开勇博士的wizard中的例子代码。原封不动。

然后分析了math_functions.h中的abs的包裹宏定义,表明我使用的VS2005的版本旧了。然后我直接换为VS2008,其它都没有变,上述问题解除。

我也是这几天,看到其它人也是有类似问题,解决方法类似,呵呵。

我是来学习的,顺便挣分!