Can I combine 'constant' and 'extern'?

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.

CUDA has no linker on the device side, so the [font=“Courier New”]extern[/font] keyword would have no meaning.

Including all device code into a single compilation unit, as you do now, thus is the only option.