making shared object file


I am trying to make a .so file with the nvcc compiler. I basically took a code that was previously written for a linear CPU and re-wrote it for a GPU.

The compiler options I used to make this file with gcc were


gcc -fPIC -c filename.c -std=c99

gcc -shared -o filename.o


Now I am trying to do the same thing but with the new code for the gpu. I see that nvcc has a -shared option and I have tried many combinations of commands.

if my file is what should I type in the command line to compile and link it to make ???

nvcc -o -shared

If you are on a 64-bit Linux distribution, you need to run instead:

nvcc -o --compiler-options ‘-fPIC’ -shared

Ok thanks, doing what you posted for the 64 bit linux system successfully creates a shared object file, but when I run my script that uses this file I get an error loading the file. To try and see if it was the compiler options that were wrong, I took the non-cuda version of my file that successfully works with my program when compiled with the gcc options above and I compiled it with nvcc with the options you provided. I get a successful compile, but when I run my script that uses the shared object file I get a bus error? can anyone explain this to me?