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 文件?


基础教程推荐
- C++结构和函数声明。为什么它不能编译? 2022-11-07
- 如何在 C++ 中初始化静态常量成员? 2022-01-01
- 如何通过C程序打开命令提示符Cmd 2022-12-09
- 在 C++ 中计算滚动/移动平均值 2021-01-01
- 静态库、静态链接动态库和动态链接动态库的 .lib 文件里面是什么? 2021-01-01
- 我有静态或动态 boost 库吗? 2021-01-01
- 常量变量在标题中不起作用 2021-01-01
- 如何将 std::pair 的排序 std::list 转换为 std::map 2022-01-01
- 如何检查GTK+3.0中的小部件类型? 2022-11-30
- 这个宏可以转换成函数吗? 2022-01-01