c++visual-studiodllstatic-libraries

How to specify the DLL file that I want my LIB to be linked to? - Visual Studio 2019


I have different versions of the same DLL file and I want to make sure it's linked to the latest version. But inside the LIB file there's only specified the "FileName.dll" which I guess it's checked in various folders until it's found.

How can I make sure it uses the one I want?

The problem is that I want to use the OpenCL library with OpenGL interactions. But since AMD-APP has been removed from the offical web I downloaded the last version and it's probably old. Since my device in clinfo gets the driver version of 1.2 (I need >= 2.0).

So I installed Radeon Software Adrenalin thingy for graphics and it gave me a new version of the DLL file (amd_opencl32.dll) which the clinfo program returns the driver version of 2.0.

The OpenCL.lib of the old version of AMD-APP is linked to a OpenCL.dll, is there any way I can link it to the new version? Am I trying something impossible or really bad?


Solution

  • LIBs only reference the DLL by name, not by version, path, or any other unique identifier.

    When your process starts, it resolves its dependency on "FileName.dll" from a specific path search algorithm. Almost always starting by looking for the DLL first in the same directory as the EXE itself before falling back to other directories. Everything you need to know is documented here:

    Dynamic-Link Library Search Order