How to generate dynamic library .so file

How to generate dynamic library file .so file with tools nvcc and g++ ?
I want to let python to call .so file in my xavider nx, but it is failed for generate .so file.
the command is :
1>nvcc --gpu-architecture=sm_72 --device-c cuda.cu
2>g++ cuda.o -fPIC -o test.so -L/usr/local/cuda-10.2/lib64 -lcudart -lcudadevrt

the error message is :
“cuda.o: relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `_Z12Conv2DKernelPfS_S_ii’ which may bind externally can not be used when making a shared object; recompile with -fPIC”

Does anyone what the reason for the issue?