链接器如何知道在哪里可以找到一个dll文件

How does the linker know where to find a dll file

我正在使用 Visual Studio,我正在尝试进入 dll。我想知道链接器如何仅从 lib 文件中知道在哪里可以找到 DLL。 我在项目设置中指定了 lib 文件及其位置,但是指定的关联 dll 文件的位置在哪里? 或许我没有正确理解这个主题。

Standard Search Order for Desktop Applications from the Microsoft Dll Search Order 文档:

If SafeDllSearchMode is enabled, the search order is as follows:

  1. The directory from which the application loaded.
  2. The system directory. Use the GetSystemDirectory function to get the path of this directory.
  3. The 16-bit system directory. There is no function that obtains the path of this directory, but it is searched.
  4. The Windows directory. Use the GetWindowsDirectory function to get the path of this directory.
  5. The current directory.
  6. The directories that are listed in the PATH environment variable. Note that this does not include the per-application path specified by the App Paths registry key. The App Paths key is not used when computing the DLL search path.

If SafeDllSearchMode is disabled, the search order is as follows:

  1. The directory from which the application loaded.
  2. The current directory.
  3. The system directory. Use the GetSystemDirectory function to get the path of this directory.
  4. The 16-bit system directory. There is no function that obtains the path of this directory, but it is searched.
  5. The Windows directory. Use the GetWindowsDirectory function to get the path of this directory.
  6. The directories that are listed in the PATH environment variable. Note that this does not include the per-application path specified by the App Paths registry key. The App Paths key is not used when computing the DLL search path.