首页 > 解决方案 > 更改 DLL 依赖项

问题描述

我正在尝试在 Visual Studio 2019 上为 libpqxx 编译一个测试程序,不幸的是,在与 Dependency Walker 检查后,我需要的一些 DLL 依赖于 64 位版本,依赖路径指向 System32 文件夹而不是SysWOW64 中的同名文件。现在我不知道如何更改 DLL 的路径,以便让程序运行。有没有办法更改我需要的 DLL 的依赖路径?

提前致谢!

编辑:

当我尝试运行程序时,我收到错误消息“libssl-1_1.dll”和“libcrypto-1_1.dll”丢失。当我将它们添加到项目文件夹时,项目被构建并且程序立即停止,并显示消息“应用程序无法正确启动 0xc00007b”。假设问题来自依赖的 x64 DLL,我使用 Dependency Walker 检查了 Visual Studio 使用的 DLL,并且有很多依赖的 x64 并且位于 System32 文件夹中。

ntdl.dll - fine
kernel32.dll -
    c:\windows\system32\KERNELBASE.DLL
    c:\windows\system32\NTDLL.DLL
    c:\windows\system32\BCRYPTPRIMITIVES.DLL
    c:\windows\system32\NSI.DLL
    c:\windows\system32\RPCRT4.DLL
    c:\windows\system32\WS2_32.DLL

KernelBase.dll-
    c:\windows\system32\NTDLL.DLL

ws2_32.dll-
    c:\windows\system32\KERNELBASE.DLL
    c:\windows\system32\NTDLL.DLL
    c:\windows\system32\RPCRT4.DLL
    c:\windows\system32\BCRYPTPRIMITIVES.DLL
    c:\windows\system32\NSI.DLL
    c:\windows\system32\WS2_32.DLL

rpcrt4.dll-
    c:\windows\system32\KERNELBASE.DLL
    c:\windows\system32\NTDLL.DLL
    c:\windows\system32\RPCRT4.DLL
    c:\windows\system32\BCRYPTPRIMITIVES.DLL
    c:\windows\system32\NSI.DLL
    c:\windows\system32\WS2_32.DLL

msvcp140d.dll-
    c:\windows\system32\KERNELBASE.DLL
    c:\windows\system32\NTDLL.DLL
    c:\windows\system32\RPCRT4.DLL
    c:\windows\system32\BCRYPTPRIMITIVES.DLL
    c:\windows\system32\NSI.DLL
    c:\windows\system32\WS2_32.DLL

vcruntime140d.dll-
    c:\windows\system32\KERNELBASE.DLL
    c:\windows\system32\NTDLL.DLL
    c:\windows\system32\RPCRT4.DLL
    c:\windows\system32\BCRYPTPRIMITIVES.DLL
    c:\windows\system32\NSI.DLL
    c:\windows\system32\WS2_32.DLL

ucrtbased.dll- fine

所以这些是 64 位的 DLL 和依赖项。我是否正确,这是导致问题的原因?我需要将任何依赖项更改为 32 位吗?

Dump of file C:\...\libpq.dll

PE signature found

File Type: DLL

FILE HEADER VALUES
             14C machine (x86)

Dump of file C:\...\lib\libpq.lib

File Type: LIBRARY

FILE HEADER VALUES
             14C machine (x86)

Dump of file C:\...\lib\pqxx.lib

File Type: LIBRARY

FILE HEADER VALUES
             14C machine (x86)

来自 dumpbin /dependents 的依赖项

kernel32.dll-
    ntdll.dll
    KERNELBASE.dll
    bunch of api-ms-win-core
    ext-ms-win-oobe-query-l1-1-0.dll
    RPCRT4.dll

KernelBase.dll-
    bunch of ext-ms-win
    ntdll.dll
    api-ms-win-eventing-provider-l1-1-0.dll

ws2_32.dll-
    bunch of api-ms-win-core
    ntdll.dll
    RPCRT4.dll

rpcrt4.dll-
    ntdll.dll
    KERNELBASE.dll
    bunch of api.ms.win

msvcp140d.dll-
    CONCRT140D.dll
    VCRUNTIME140D.dll
    ucrtbased.dll
    KERNEL32.dll

vcruntime140d.dll-
    ucrtbased.dll
    KERNEL32.dll

ucrtbased.dll-
    bunch of api-ms-win-core

标签: dllwindows-10visual-studio-2019

解决方案


推荐阅读