NVCC - New to CUDA but not new to SW Development

Hi. I have a question regarding developing/building CUDA code within some existing software. I am new to this so pardon the question if it’s obvious to most.

So I’ll begin by saying that I went through the provided examples, built all them and have executed them. No problem. I’ve studied the build system (makefiles) and have looked over the user and reference guides. Again, No problem. Now I’m trying to implement my own, one step at a time. As a first step, I went to an existing code that I have with its Makefile and added all the CUDA specific CFLAGS and LDFLAGS (i.e. compile and linker flags) and also changed the gcc to use the nvcc. Without adding any CUDA specif code yet, nvcc is building the object code for each module but failing on the link looking for a main.c. The Makefile and code for this existing code builds a shared object (i.e. a .so) and not a standalone executable. As a simple experiment, leaving all the flags in place and just changing back to gcc versus nvcc, the makefile builds the .so as expected. So now the question becomes, does nvcc only build standalone executables and requires and explicit main?

No, nvcc can be used to build shared objects (.so)

This can be discovered/confirmed by reading the nvcc manual:


for example:


I’m already doing this. so I’m not sure why it’s searching for a main. there is no main needed.
Something else is missing.