I have recently worked on integrating
CUDA in a project and have stumbled upon a couple of problems on Windows in combination with
Clang (using the GNU-like command-line) and
To demonstrate the problems there is a sample GitHub repository cmake_export_all_symbols.
There are two problems which occur - both are in the linking phase.
- The LLVM linker
lld-link.execannot find the library include path for CUDA, and produces the following two error messages:
clang++: error: no such file or directory: 'cudadevrt.lib' clang++: error: no such file or directory: 'cudart_static.lib'
WINDOWS_EXPORT_ALL_SYMBOLSproperty produces a
CMakeFiles\lib.dir\.\exports.def) file, but it cannot be consumed by the linker. This seems to be somehow caused after
enable_language(CUDA)call or when
CUDAis one of the languages listed in the CMake
clang++: error: no such file or directory: '/DEF:CMakeFiles\lib.dir\.\exports.def'
The repository listed above works all fine when one changes
Regarding the exact versions of the tools used:
I wanted to ask, whether these are known problems (as I couldn’t find any information here and in the issue tracker) and if there are ways to cleanly mitigate those problems.
So far, my teammates and I have found a workaround:
- The first one we solved was by placing the missing
.libfiles in the corresponding build directory in a pre-link step.
- Here we were lucky because all of our targets which use
WINDOWS_EXPORT_ALL_SYMBOLSare independent of all our targets, which use
CUDA. So we made sure that all targets using
WINDOWS_EXPORT_ALL_SYMBOLSare compiled and linked before any
enable_language(CUDA)call is encountered.