Cuda5.5不支持C++11的解决方法

    最近在做的项目中既用到了Cuda,同时又用到了C++11的一些新的特性,在用gcc编译的时候会出现错误。

    错误提示为:

/usr/include/c++/4.6/x86_64-linux-gnu/./bits/c++config.h(159): error: identifier "nullptr" is undefined

/usr/include/c++/4.6/x86_64-linux-gnu/./bits/c++config.h(159): error: expected a ";"

/usr/include/c++/4.6/bits/exception_ptr.h(93): error: incomplete type is not allowed

/usr/include/c++/4.6/bits/exception_ptr.h(93): error: expected a ";"

/usr/include/c++/4.6/bits/exception_ptr.h(112): error: expected a ")"

/usr/include/c++/4.6/bits/exception_ptr.h(114): error: expected a ">"

    经过查找资料后发现是由于Cuda5.5目前还不支持C++11。为了解决这个问题,我们要将cuda程序也就是以.cu结尾的文件单独编译,在编译cuda程序的时候指定编译标准为C++03,这样就不会发生上述的错误。

    我的具体解决方案是:在编译cuda文件的CMakeLists.txt中用命令SET(CUDA_NVCC_FLAGS --compiler-options "-std=c++03";-arch=sm_20)指定nvcc的编译选项。

    参考资料:

         http://stackoverflow.com/questions/16149538/cuda-and-thrust-library-trouble-with-using-cuh-cu-and-cpp-files-together-wit

转载请注明出处。


评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值