nvcc: C++11 standard in CUDA frontend? (dependencies, gcc, Windows vs. Linux)

Hi everyone,

we are developing signal processing applications using CUDA (6.0.26_rc).
We have started a new project using code from the C++11 standard.

Our code compiles fine with Mircosoft Visual Studio 2012 on Microsoft Windows (32 bit).
Unfortunately compiling under a Debian Wheezy Linux using gcc on a 64 bit machine does not work.
Both builds have been automatically generated using CMake.

The problem seems to relate to the use of C++11 language specific code.
Although the .cu files and their .h files themselves do only include header files of C++11 code.
I have read that there are issues concerning the C++11 standard on stackoverflow, but the posts were quite old.

We are wondering why it is working (using the same nvcc version) under Windows and not under Linux. Maybe we are missing something. Is this CUDA frontend specific? If required I can provide output of the build process.

Help is very much appreciated. Thank you!

You don’t mention what gcc version on Debian, if older than 4.8.1, it does not support all C++11 constructs… look at posts 4-5 of this thread:

Hi vacaloca,

thank you for your reply. Yesterday I have collected some more information that might or might not help.

  1. nvcc -Xcompiler “-std=c++0x”

When calling the nvcc under Debian with gcc (Debian 4.7.2-5) 4.7.2 as the compiler which is used we get this and other errors:

/usr/include/c++/4.7/x86_64-linux-gnu/./bits/c++config.h(177): error: identifier “nullptr” is undefined

I have found the following forum postings on the internet and extracted the main statements:

CUDA 5.0: no support for GCC 4.7, no support for C++11 features
nvcc does not understand C++11 syntax used in the standard includes of GCC 4.6

“nvcc does not support c++11 constructs, even if they are supported by the host compiler”
‘The reason it isn’t as simple as passing -std=c++0x to the host compiler is that nvcc has to parse the entirety of the code in order to split it into its __host__and device halves. This preprocess happens before the host compiler is presented with any code at all, so nvcc’s parser needs to be able to grok c++11 for it to work.’


  1. calling nvcc without the -Xcompiler flag (-std=…) or setting
    SET( CUDA_PROPAGATE_HOST_FLAGS OFF ) in Cmake (which should have the same effect)

The following warning appears:

/usr/include/c++/4.7/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard.
This is currently experimental and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.

(due to inclusion of #include , use of scoped enumeration types, std::shared_ptr and probably others)


I read the output of the build process and could cut it down to the following two different error situations:

  • when leaving out the -Xcompiler “-std=c++0x” flag the build process already stops when the dependency file is geenerated
  • when passing the -Xcompiler flag the build stops when generating the object file (.cu.obj/ .cu.o)
  1. Windows vs. Linux

For me it’s still not that clear what the difference is for Windows and Linux as the build commands (cmake + nvcc) are almost the same. I have made copies of the dependency files, not sure if it makes sense to compare them - Windows and Linux.

I also have found the following forum posts according to the Windows vs. Linux problem:

“I checked with the compiler team, and from what I understand, C++11 features that are supported by the host compiler at default settings should work in the host code portion of a .cu file. However, C++11 features that require the use of specific additional compiler flags (e.g. -std=c++11 with g++) to turn them on are not supported.”
“For now it seems advisable to move host code using C++11 features into separate .cpp files so it can be processed directly by the host compiler.”

“For the host code, nvcc supports whatever part of the C++ ISO/IEC 14882:2003 specification the host c++ compiler supports.”

Can you say if this is a nvcc or a gcc problem?
I also compared the nvcc versions:

nvcc: NVIDIA ® Cuda compiler driver
Copyright © 2005-2013 NVIDIA Corporation
Built on Tue_Jan_28_00:09:34_PST_2014
Cuda compilation tools, release 6.0, V6.0.1

nvcc: NVIDIA ® Cuda compiler driver
Copyright © 2005-2013 NVIDIA Corporation
Built on Sat_Jan_25_17:33:19_PST_2014
Cuda compilation tools, release 6.0, V6.0.1

According to my /usr/local/cuda/include/host_config.h file GCC >4.8 not supported.
I might try 4.8.1 but I’d like to make sure that this is a gcc problem as I’d have to compile it from sources (at least there is no package available for Debian Wheezy?).

Edit: to put the C++11 code in separate .cpp files seems to be the general solution. Though this might not work for us as the kernel gets some arguments that refer to classes which at least include some C++11 code; at least some effort would be neccessary to put it.

Thank you!

I might be wrong as I have not attempted this, but I believe the solution in Linux is to compile your cpp files separately with gcc >= 4.8.1 and have nvcc compile the cu files using gcc 4.7, assuming nvcc doesn’t like 4.8.1 after removing the trestriction in the host_config.h file you mentioned.

See here for an example:

Another option would be to use the Intel compiler:

I tried again with CUDA 6.5 RC and passing the flag -std=c++11 still does not work… (Ubuntu 14.04, gcc 4.8.2).

/usr/lib/gcc/x86_64-linux-gnu/4.8/include/stddef.h(432): error: identifier "nullptr" is undefined

Are there any plan to support the 2011 standard at some point? CUDA 7.0 maybe?

1 Like

Hi Morph208,

thank you for trying this out. As a solution we finally had to move all the C++11 code out of the .cu files.


What are the plans from NVidia to support C++11 code?

It is a shame to have to split our stuff just to accomodate this lack of functionality.

How do you configure NSight to compile .cpp files with g++ and .cu with nvcc?

There is experimental support for c++11 code in CUDA 6.5RC, based on this announcement:


There is experimental support for c++11 code in CUDA 6.5RC, based on this announcement:


Check my solution: