How to generate dynamic library .so file

Does anyone know how to generate dynamic library .so file with nvcc and g++? I want to use python to call .so file from xavier nx .

Best Regards.