referencing CUDA library functions in my library


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

nvcc -L/someDir -L/usr/local/cuda/lib64 -lmylib -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 instead of

Show the exact compile command you used to build

You may want to read this:

[url]c++ - What does exactly the warning mean about hidden symbol being referenced by DSO? - Stack Overflow

It’s an error. The linking failed.

Yes, the library’s name is

The command is:

nvcc -L/usr/local/cuda/lib64 -L…/ -lmylib -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);