Add CUDA to QT project under Visual Studio 2022

I am working with Visual Studio and the QT extension to work on a simple QT program. I installed the CUDA toolkit for Visual Studio 2022 and it works. When I create a dedicated “CUDA” project, I can run the sample code and utilities just fine.

However, I need to make CUDA work inside the QT project, which was not created as a CUDA project. In the installation guide (Installation Guide Windows :: CUDA Toolkit Documentation) under section 4.4, it is explained how to add CUDA to an existing project by adding the dependency. However, the program won’t compile, unless the main function is declared in a “CUDA-managed” source file, which the file containing the main-function of the QT program is not.

I realize that the different compilers (QT, MSVC and NVCC) may collide here, so how do I make this work?

This post: How to call cuda function from c++ file?

solved my problem

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