Using C++ objects in nvcc-compiled file? No luck mixing gcc/nvcc...

Hi,

I have the following setup:

file A.cpp is compiled with g++ into A.cpp.o
file B.cu is compiled with nvcc into B.cu.o (B has no kernel functions)
Then the two output files are linked with g++ to produce an executable.

A.cpp defines a class and B.cu uses that class by including A.h. My problem is that during linking, g++ reports an “undefined reference” error on every line where B.cu uses the class defined in A.cpp.

Is it possible to do what I’m trying to do? Sorry if this is a terribly basic question, I’m brand new to CUDA.

Thanks.

can you put here your compile code?

Sorry, never mind, this seems to be the result of an unrelated bug (feature?) in g++. The functions I was trying to call are defined as inline, and g++ has problems linking against inline functions when they’re defined in the .cpp file.

If you work on Linux you can see the commands that would be executed with “make -n”.

what is the version of g++? because 4.3 isn’t valid for cuda.

you have many examples with .cpp and .cu. So see these examples and their compile process too.