Reputation: 53
I'm using the CUDA Driver API in a project. When I execute the project in a PC that doesn't have a NVIDIA GPU, it gives "nvcuda.dll was not found".
The problem is: this DLL is only distributed with the GPU driver, not like in the Runtime API where you can put the DLL needed with your executable. I need to load this DLL in runtime, and if it doesn't exist I will know that CUDA is not available. I'm using Visual Studio 2012 Professional.
Is there a way to do that?
Upvotes: 1
Views: 4363
Reputation: 151799
Windows provides an API function (LoadLibrary
) to load DLLs into memory at runtime. You provide a LPCTSTR
(null terminated pointer to a const TCHAR
) containing the name/path of the DLL you want to load. If you provide a relative path, Windows will scan PATH
and the executable's current directory for the file. If you provide an absolute path, Windows will use that.
If LoadLibrary
returns NULL
, Windows couldn't find the file.
Upvotes: 1
Reputation: 710
Create a small "Launcher" app that will check if system meets your requirements and will launch the main application or display an error depending on the check results.
To check if a DLL is available you can use LoadLibrary()
as previously suggested.
Upvotes: 0