【发布时间】:2016-02-10 09:04:56
【问题描述】:
我想将依赖项(几个 DLL 文件)复制到一个单独的子目录中。安装我的程序后,目录结构如下:
- dll/
- a.dll
- b.dll
- 样品/
- pg.exe
我的脚本的相关部分如下:
[Dirs]
Name: "{app}\sample"
Name: "{app}\dll"
[Files]
Source: "pg.exe"; DestDir: "{app}"; Flags: ignoreversion
; icon file
;Source: "pg.ico"; DestDir: "{app}"
; sample ini and geoemtry file
Source: "geometry.xml"; DestDir: "{app}\sample"
Source: "ini.xml"; DestDir: "{app}\sample"
; DLL
Source: "a.DLL"; DestDir: "{app}\dll"; Flags: onlyifdoesntexist
Source: "b.DLL"; DestDir: "{app}\dll"; Flags: onlyifdoesntexist
当我在 VM 中测试我的安装程序时,我收到一条错误消息,指出找不到 a.DLL。如果我只是将a.DLL 从dll/ 复制到可执行文件的目录,问题很快就解决了。
- 是否有必要将所有 dll 与可执行文件放在同一级别?
- 或者有没有办法让可执行文件在子目录 dll/ 中找到它的依赖关系?
【问题讨论】:
-
您使用的是隐式还是显式 DLL 链接?
-
我不知道。如何发现?
-
在代码中使用
LoadLibrary或LoadLibraryEx实现显式链接,使用dllimport/dllexport语句实现隐式链接,并且DLL必须具有相应的导入库(.LIB)文件。有关详细信息,请参阅我的答案。
标签: c++ windows dll inno-setup