Host compile error upon including host_vector.h

Hello, I’m trying to compile the code

#include <thrust/host_vector.h>
int main(void){ return 0xabacab; }

with (taken from thrust cpp_integration repository)

g++ -O2 -c test.cpp -I/usr/local/cuda-12.5/targets/x86_64-linux/include/

and the following compile errors show:

In file included from /usr/local/cuda-12.5/targets/x86_64-linux/include/cuda/std/detail/libcxx/include/__cccl_config:17,                                                                                                                                                                                                
                 from /usr/local/cuda-12.5/targets/x86_64-linux/include/cuda/__cccl_config:14,                                                                                                                                                                                                                          
                 from /usr/local/cuda-12.5/targets/x86_64-linux/include/thrust/detail/config/config.h:24,                                                                                                                                                                                                               
                 from /usr/local/cuda-12.5/targets/x86_64-linux/include/thrust/version.h:31,                                                                                                                                                                                                                            
                 from /usr/local/cuda-12.5/targets/x86_64-linux/include/thrust/detail/config.h:22,                                                                                                                                                                                                                      
                 from /usr/local/cuda-12.5/targets/x86_64-linux/include/thrust/host_vector.h:25,                                                                                                                                                                                                                        
                 from test.cpp:1:                                                                                                                                                                                                                                                                                              
/usr/local/cuda-12.5/targets/x86_64-linux/include/thrust/detail/execution_policy.h:55:11: error: ‘__host__’ does not name a type                                                                                                                                                                                        
   55 | constexpr _CCCL_HOST_DEVICE                                                                                                                                                                                                                                                                                            
      |           ^~~~~~~~~~~~~~~~~                                                                                                                                                                                                                                                                                            

plus many other errors like it. I’ve no idea whats happening. Also tried compiling with nvcc. In case of nvcc, if I rename test.cpp to test.cu, it compiles fine.

That’s what you should do.

The thing you link is a Rocm repo. I don’t think you are going to get help from NVIDIA for that.

1 Like

Shame on me :(

Didn’t realize that. Thanks for the response.

Can you delete the post?

In any case, the example provided is also located at cccl/thrust/examples/cpp_integration at main · NVIDIA/cccl · GitHub

Probably best to file a thrust issue then.

I didn’t have any trouble compiling your test case with g++ on CUDA 12.2. I acknowledge you are using CUDA 12.5, and I don’t have that setup available conveniently at the moment.

1 Like