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


- 近似搜索的工作原理 2021-01-01
- 使用/clr 时出现 LNK2022 错误 2022-01-01
- 如何对自定义类的向量使用std::find()? 2022-11-07
- 与 int by int 相比,为什么执行 float by float 矩阵乘法更快? 2021-01-01
- 静态初始化顺序失败 2022-01-01
- Stroustrup 的 Simple_window.h 2022-01-01
- C++ 协变模板 2021-01-01
- 从python回调到c++的选项 2022-11-16
- 一起使用 MPI 和 OpenCV 时出现分段错误 2022-01-01
- STL 中有 dereference_iterator 吗? 2022-01-01