Linker error

Hi. I’m new to CUDA and I am not able to resolve this linker error.

/usr/lib/gcc/x86_64-linux-gnu/5/…/…/…/x86_64-linux-gnu/crt1.o: In function _start': (.text+0x20): undefined reference to main’
collect2: error: ld returned 1 exit status

I need a .so file for a python script

I am using “nvcc -arch=compute_35 -rdc=true” for compilation

cross posting:

nvcc -Xcompiler -fPIC -shared -arch=compute_35 -rdc=true -o

That worked. Thanks. Can you explain what you did there?

-shared informs the toolchain that we want to build a DSO, not an executable. CUDA is in the C++ family and a standard executable built from C++ code must include a function main().

-Xcompiler is an escape switch that passes the following switch to the host compiler.

-fPIC instructs the toolchain to produce position-independent code, which is required for DSOs on x86 I believe (but not necessarily other CPU architectures, otherwise it could be automatically turned on by -shared)

Thanks a ton guys.