Compile thrust code with clang++-4.0

I have been using clang+±4.0 for compiling my CUDA programs but recently I started to use thrust library. I have trouble compiling with clang. Is there anyway to fix the error. This is how I compile my CUDA codes.

clang++-4.0 -o main -L/usr/local/cuda/lib64 -lcudart -std=c++14

The reason, Why I am using clang is that it supports the latest C++ standards.

If you’re on Linux, try -lcudart_static, that’s the official suggestion on their docs for non-OSX:

You should probably also specify the architecture, e.g. --cuda-gpu-arch=sm_35.

In my own personal experience I ran into a lot of trouble with clang 4 and cuda. I haven’t since retried with clang 5, but I’d be willing to bet higher success rates. My particular code (that worked with NVCC no problem) had a lot of templates in device code / global kernels, and clang seems to have gotten to confused by them.

Hope one of those two helps, but there might be a different problem here altogether. Which version of CUDA are you using? Officially, c++14 is only supported with CUDA 9. CUDA 8 requires c++11.


I need some more information to investigate this. If this is still a problem for you, please provide:

  • A minimal test case; e.g. a complete, standalone program that is as small as possible and has few/no dependencies on other software.
  • The entire sequence of commands/actions that reproduce the bug (using the minimal test case).
  • The unabbreviated outputs of those commands/actions including files, stdout/stderr and logs.
  • A description of the environment where the problem occurs (type and version of the hardware, OS, kernel, compiler and any other relevant software).

– Bryce

Bryce, I love your impressive credentials footer, in particular this one