referencing CUDA library functions in my library

Hi,

I implemented a small library in directory /someDir/mylib.so, and I’d like to link it to my CUDA programs by:

nvcc -L/someDir -L/usr/local/cuda/lib64 -lmylib cuda_prog.cu -o cuda_prog

I got the following error:

/usr/bin/ld: tmp/cuda_prog: hidden symbol `cudaEventSynchronize’ in /usr/local/cuda/lib64/libcudart_static.a(libcudart_static.a.o) is referenced by DSO

My understanding is that the cuda function symbols in the CUDA library are not visible. But is there any way to get around this?

Is it a warning or an error?

Shouldn’t you have named that lib as libmylib.so instead of mylib.so?

Show the exact compile command you used to build mylib.so

You may want to read this:

http://stackoverflow.com/questions/23696585/what-does-exactly-the-warning-mean-about-hidden-symbol-being-referenced-by-dso

It’s an error. The linking failed.

Yes, the library’s name is libmylib.so.

The command is:

nvcc -L/usr/local/cuda/lib64 -L…/ -lmylib cuda_prog.cu -o cuda_prog -O3

I actually read that post from stackoverflow before, but it didn’t help me solve the problem. I’m trying to see whether somebody knows how to circumvent this problem.

Sorry that I didn’t ask the question clearly. Actually, I tried to redefine some cuda library functions, such as cudaMalloc, by using dlsym. For example, I did:

cudaMalloc = (typeof(cudaMalloc))dlsym(RTLD_NEXT, myCudaMalloc);