tags:

views:

124

answers:

1

Having just learned that many cpp features (including the stl vector class) do not work in cu files. Even when using them in the host code.

Since I have to use a C++ class which uses STL I cannot compile my CU file which invokes the kernel. (I don't use any STL features in the CU file, but I think the include is the problem.)

I tried to build this by using cmake with

cuda_add_executable(
Blah
Blah.cu
BlahKernel.cu
HostCodeWithVector.cpp
)

which obviously doesn't work. The question now arises if it's possible to build HostCodeWithVector.cpp with gcc instead of nvcc and the link it somehow..?

+2  A: 

since __host__ is just what runs on your CPU you can compile this part using any compiler (MSVC, gcc) and then link with nvcc result. So you should just leave only GPU interop in CU files, everything else put into CPP.

Andrey
Ok.. and how can I tell this cmake..?
Nils
@Nils read documentation of gcc and nvcc. make them produce object files. then take linker from gcc and link them together.
Andrey
Thx for ur answer, the problem was trying to build 64bit which (still!) does not work with CUDA on a Mac and not with STL. I did it correct I think. " All of the non CUDA C files are compiled using the standard build rules specified by CMAKE and the cuda files are compiled to object files using nvcc and the host compiler." Says http://cmake.org/cmake/help/cmake-2-8-docs.html
Nils