I would like to organise my CUDA code into separate object files to be linked at the end of compiling, as in C++. To that end I’d like to be able to declare an extern pointer to constant memory in a header file, and put the definition in one of the .cu files, also following the pattern from C++. But it seems that when I do so, nvcc ignores the ‘extern’ - it takes each declaration as a definition, and thus I have multiple definitions of the same symbol when linking time comes. Is there a way around this?
My current solution is to use Makefile magic to glob together all my .cu files and have, in effect, one big translation unit but some semblance of file organisation. But this is already slowing down compiles noticeably, since a change to any one of my classes means recompiling all of them; and I anticipate adding several more classes.