CUDA 9: "hidden symbol `cudaGetErrorString' is referenced by DSO" in debug mode


I have tried to recompile my program using CUDA 9, but unfortunately the linking phase failed with the following error, but only in Debug mode:

hidden symbol `cudaGetErrorString' in /usr/local/cuda-9.0/lib64/libcudart_static.a(libcudart_static.a.o) is referenced by DSO

This works when the build happens in Release Mode, and it also works both in Release and Debug mode with CUDA 8.

I’m using GCC 5.3 on Fedora 26, but I have also tried GCC 6.2 which has the same error.

Yes, I have read the relevant Stackoverflow thread, but it doesn’t help me. The build is managed by CMake, which automatically links to libcudart_static.a.

It turns out that the message was actually somewhat misleading, and it was simply a missing reference to libcudart_static.a.

The target executable was linked with multiple dynamic shared libraries, one of which had a reference to cudaGetErrorString. However, in CMake, this library was added as “add_library” and not as “cuda_add_library”.

Adding this library with “cuda_add_library” in CMake correctly links it to libcudart_static.a.

I do not know why this worked with CUDA 8.