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


I have the following setup:

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

A.cpp defines a class and uses that class by including A.h. My problem is that during linking, g++ reports an “undefined reference” error on every line where 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.


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.