VS2022 CUDA compile: missing a library, but which one?

I’m on Windows 10 in Visual Studio 2022 trying to compile some CUDA code. I’ve used the CUDA 11.7 integration with VS to add a CUDA project (and I have successfully compiled CUDA on Windows before). I’ve added a few extra required libraries to the Properties->Linker->Additional Dependencies like ‘nvrtc.lib’ to get rid of some unresolved symbols but I can’t figure out how to get rid of the last few missing symbols:

1>proto.cu.obj : error LNK2001: unresolved external symbol cuGetErrorString
1>proto.cu.obj : error LNK2001: unresolved external symbol cuGetErrorName
1>proto.cu.obj : error LNK2001: unresolved external symbol cuModuleLoadData
1>proto.cu.obj : error LNK2001: unresolved external symbol cuModuleLoadDataEx
1>proto.cu.obj : error LNK2001: unresolved external symbol cuModuleUnload
1>proto.cu.obj : error LNK2001: unresolved external symbol cuModuleGetFunction
1>proto.cu.obj : error LNK2001: unresolved external symbol cuLinkCreate_v2
1>proto.cu.obj : error LNK2001: unresolved external symbol cuLinkAddData_v2
1>proto.cu.obj : error LNK2001: unresolved external symbol cuLinkAddFile_v2
1>proto.cu.obj : error LNK2001: unresolved external symbol cuLinkComplete
1>proto.cu.obj : error LNK2001: unresolved external symbol cuLinkDestroy
1>proto.cu.obj : error LNK2001: unresolved external symbol cuLaunchKernel

Hoping someone might see the pattern and know what is missing.

–Roger

These symbols are all from the CUDA driver API (as opposed to the CUDA runtime API), note the leading cu. You would need to link to cuda.lib rather than cudart.lib, which most CUDA projects probably link against.

You may already be linking to the correct libraries, but the compiler might not find it because it has not been pointed at the correct location, or you may be linking statically and the libraries might be given to the linker in the wrong order.

I don’t use the Visual Studio IDE, so I cannot help with configuring the link process in the IDE.

This was it. I just needed to add cuda.lib into that long list of extra libraries.

Thank you, @njuffa!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.