CMake: how to determine all the .DLL/.SO files that are need for an executable?(CMake:如何确定可执行文件所需的所有 .DLL/.SO 文件?)
问题描述
假设我的程序需要几个 DLL 才能工作.我应该在我的发行版中向用户提供这些 DLL.现在我需要 QtCore4.DLL、QtGui4.DLL、msvcp90.DLL、msvcr90.DLL、mylib.DLL、Kernel32.DLL...
Let's assume my program needs several DLL's to work. I should provide that DLLs to the user in my distribution. For now I need QtCore4.DLL, QtGui4.DLL, msvcp90.DLL, msvcr90.DLL, mylib.DLL, Kernel32.DLL...
如果 CMake 能够获得 DLL(或 .SO)文件的完整列表,那就太好了.然后我会从该列表中删除诸如Kernel32.DLL"之类的项目,并将这些 DLL 复制到我的发行版中.
Would be nice if CMake could get full list of DLLs (or .SO) files. Then I would remove items like "Kernel32.DLL" from that list and copy the DLLs to my distribution.
我不能保证下一个构建将在相同版本的 Visual Studio 上完成,因此硬编码路径如C:Program FilesMicrosoft Visual Studio 9.0VC edistx86Microsoft.VC90.CRT" 或 "E:Qt4.6.3" 不适合搜索 DLL.
I can't guarantee the next build will be done on the same version of the Visual Studio, so hard-coding paths like "C:Program FilesMicrosoft Visual Studio 9.0VC edistx86Microsoft.VC90.CRT" or "E:Qt4.6.3" is not good for searching for the DLLs.
谢谢!
推荐答案
您可以在 windows 上使用 Dependency Walker(或来自 Visual Studio 的 cmd-line dumpbin 工具).然而,这并不是真正的 CMake 解决方案,而且 Cmake 也没有真正的标准解决方案.
You can use Dependency Walker on windows (or the cmd-line dumpbin tool from visual studio). However this is not really a CMake solution and there is not really standard solution with Cmake.
但是,InstallRequiredSystemLibraries 模块,您可以使用它来获取系统 dll(msvc[r|p]90.dll 与 msvc 和 mingw10.dll 与 mingw).
There is, however, the InstallRequiredSystemLibraries module, which you can use to get the system dlls (msvc[r|p]90.dll with msvc and mingw10.dll with mingw).
这篇关于CMake:如何确定可执行文件所需的所有 .DLL/.SO 文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:CMake:如何确定可执行文件所需的所有 .DLL/.SO 文件?
基础教程推荐
- Windows Media Foundation 录制音频 2021-01-01
- 如何使图像调整大小以在 Qt 中缩放? 2021-01-01
- 管理共享内存应该分配多少内存?(助推) 2022-12-07
- 如何在不破坏 vtbl 的情况下做相当于 memset(this, ...) 的操作? 2022-01-01
- 从 std::cin 读取密码 2021-01-01
- 如何“在 Finder 中显示"或“在资源管理器中显 2021-01-01
- 在 C++ 中循环遍历所有 Lua 全局变量 2021-01-01
- 为 C/C++ 中的项目的 makefile 生成依赖项 2022-01-01
- 使用从字符串中提取的参数调用函数 2022-01-01
- 为什么语句不能出现在命名空间范围内? 2021-01-01