问题描述
我想CUDA集成到现有的aplication至极使用的boost ::精神。
I'm trying to integrate CUDA to an existing aplication wich uses boost::spirit.
隔离的问题,我发现了以下code不NVCC copile:
Isolating the problem, I've found out that the following code does not copile with nvcc:
main.cu
:
#include <boost/spirit/include/qi.hpp>
int main(){
exit(0);
}
与 NVCC -o cudaTest main.cu
我得到了很多的错误,可以看到的。
Compiling with nvcc -o cudaTest main.cu
I get a lot of errors that can be seen here.
但是,如果我更改文件名以的main.cpp
,并再次编译使用 NVCC
,它的工作原理。这里发生了什么,我该如何解决这个问题?
But if I change the filename to main.cpp
, and compile again using nvcc
, it works. What is happening here and how can I fix it?
推荐答案
NVCC
有时也有麻烦编制复杂的模板code,如升压被发现,即使在code仅在 __主机使用__
功能。
nvcc
sometimes has trouble compiling complex template code such as is found in Boost, even if the code is only used in __host__
functions.
当一个文件的扩展名是的.cpp
, NVCC
不执行解析本身,而是转发code主机编译器,这就是为什么你根据文件扩展名观察不同的行为。
When a file's extension is .cpp
, nvcc
performs no parsing itself and instead forwards the code to the host compiler, which is why you observe different behavior depending on the file extension.
如果有可能,尽量检疫code依赖于升压到的.cpp
文件,这不需要由解析NVCC
。
If possible, try to quarantine code which depends on Boost into .cpp
files which needn't be parsed by nvcc
.
我也一定要试试 NVCC
其中附带最近的。 NVCC
的模板支撑在每个版本中得到改善。
I'd also make sure to try the nvcc
which ships with the recent CUDA 4.1. nvcc
's template support improves with each release.
这篇关于为什么NVCC无法编译CUDA文件,提振精神::?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!