I read it here that CUDA 6.5 has started support for C++11 :
我在这里看到CUDA 6.5已经开始支持c++ 11:
https://groups.google.com/forum/#!topic/thrust-users/R37GIkMG4tk
https://groups.google.com/forum/ # ! / thrust-users / R37GIkMG4tk话题
But when I compile an example code below, I got
但是当我编译下面的示例代码时,我得到了
$ nvcc -std=c++11 cu-gcc11.cu -o test
$ nvcc化= 11 cu-gcc11 c++。铜- o测试
nvcc warning : The -c++11 flag is not supported with the configured host compiler. Flag will be ignored.
nvcc警告:配置的主机编译器不支持-c++11标志。标志将被忽略。
cu-gcc11.cu(7): error: explicit type is missing ("int" assumed)
cu-gcc11.cu(7): error:显式类型缺失(假设为“int”)
My setting : CUDA 6.5, g++ 4.5, ubuntu 12.04
我的设置:CUDA 6.5, g++ 4.5, ubuntu 12.04
Codes :
代码:
#include <cuda.h>
#include <iostream>
__host__ void test() {
float a = 12.;
double b = 3.;
auto c = a * b;
std::cout << c << std::endl;
}
int main()
{
test();
return 0;
}
2 个解决方案
#1
5
C++11 support in nvcc is experimental at this time. In order to properly use it you will need an appropriate configuration. This is not documented anywhere AFAIK, but you should have good results with either Fedora 20 or Ubuntu 14.04, both of which are supported configs for cuda 6.5 and include GCC 4.8.x.
在nvcc中,c++ 11的支持是实验性的。为了正确地使用它,您需要一个适当的配置。这在任何地方都没有被记录,但是您应该在Fedora 20或Ubuntu 14.04中得到很好的结果,这两个都支持cuda 6.5的configs,并且包括GCC 4.8.x。
In your case your GCC version is just too old.
在您的例子中,您的GCC版本太老了。
#2
1
I don't think -std=c++11
was available in GCC 4.5. Try -std=c++0x
.
我认为在GCC 4.5中没有-std=c++11。尝试化= c++ 0 x。
#1
5
C++11 support in nvcc is experimental at this time. In order to properly use it you will need an appropriate configuration. This is not documented anywhere AFAIK, but you should have good results with either Fedora 20 or Ubuntu 14.04, both of which are supported configs for cuda 6.5 and include GCC 4.8.x.
在nvcc中,c++ 11的支持是实验性的。为了正确地使用它,您需要一个适当的配置。这在任何地方都没有被记录,但是您应该在Fedora 20或Ubuntu 14.04中得到很好的结果,这两个都支持cuda 6.5的configs,并且包括GCC 4.8.x。
In your case your GCC version is just too old.
在您的例子中,您的GCC版本太老了。
#2
1
I don't think -std=c++11
was available in GCC 4.5. Try -std=c++0x
.
我认为在GCC 4.5中没有-std=c++11。尝试化= c++ 0 x。