缺少 zlib.dll
我正在构建一个 win32 可执行文件。编译器是MinGW的最新版本。库依赖项是 GLUT 和 libpng。
我首先在Windows 7机器上进行测试,并且必须获取libpng3.dll和freeglut32.dll。然而,在 XP 上,我必须(另外)获取 zlib1.dll。
XP机器是全新安装的VM,所以我怀疑新的win7机器也可能缺少zlib1。
我的问题是如何找出我需要分发哪些 dll?我如何先验地知道我的程序需要哪些动态库才能在特定系统上运行?我想这就是安装程序的用途......我猜测安装程序所做的就是检查系统以找出哪些依赖项不满足,然后提供它们。这样,如果我要分发我的程序,我可以检查用户的计算机是否已经有 zlib1.dll,如果已经在系统目录中找到了 zlib1.dll,我就不会安装它。然而,我从未找到一个文档专门对我说“libpng 需要 zlib”,因此,直到我在缺少 zlib 的计算机上测试可执行文件时,我才意识到这种依赖性。如何在不重新安装要测试的每个操作系统的每个版本的情况下创建依赖项列表?
我的一个想法是反编译可执行文件,或者通过某种方法检查链接过程,以找到在运行时链接的所有库。现在的问题是弄清楚其中哪些应该已经存在,以及哪些我应该在发行版中提供。
编辑:好的,我看了,我下载的libpng安装确实在其bin目录中提供了zlib1.dll。所以不包括它几乎是我的错。无论如何,丹尼尔的答案是确定的。
I am building a win32 executable. The compiler is the latest version of MinGW. The library dependencies are GLUT and libpng.
I first tested on a windows 7 machine, and had to obtain libpng3.dll and freeglut32.dll. However, on XP, I had to (in addition) acquire zlib1.dll.
The XP machine was a VM with a fresh install, so I suspect a fresh win7 machine may also be lacking zlib1.
My question is how do I go about finding out which dll's I need to distribute? How do I know, a priori, which dynamic libraries are needed for my program to run on a particular system? I suppose this is what installer programs are for... I'm guessing that what the installer does is look through the system to find out which dependencies are unsatisfied, and then provides them. So this way if I were to distribute my program I could check if the user's machine already has zlib1.dll, and I won't install zlib1.dll if it's already found in the system directory. However I never found a document that said to me specifically, "libpng requires zlib", and so, until such point as I tested the executable on a machine lacking zlib, I was unaware of this dependency. How can I create my dependency list without having a fresh install of each version of every operating system to test on?
One idea I have is to decompile the executable, or through some method examine the linking process, to find all the libraries that are being linked at runtime. The problem now becomes figuring out which of these are supposed to already be there, and which of them I could be expected to provide in the distribution.
edit: Okay, I looked, and the installation of libpng I downloaded did provide zlib1.dll inside its bin directory. So not including it is pretty much my fault. In any case, Daniel's answer is definitive.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Dependendy Walker 显示您程序的所有部门。
Dependendy Walker shows all deps of your program.
在我看来,这个问题的正确答案是从源头开始,而不是使用 Dependency Walker 对解决方案进行逆向工程,尽管它无疑是一个非常棒且有用的工具。
Dependency Walker 的问题在于,它仅告诉您程序的某一特定运行在运行该程序的操作系统上需要什么。如果您的应用程序中有任何动态加载依赖项,那么只有在确保使用 Dep 分析了该应用程序时,您才会选择这些依赖项。沃克并迫使它通过那些动态负载。
我解决这个问题的首选方法是从您自己的源代码开始,分析并理解它所依赖的内容。这样做通常很容易,因为您很了解它。
您需要了解编译器的部署要求是什么。您通常可以选择静态和动态链接到 C++ 运行时。显然,动态链接会产生部署要求。
您还可能链接到第 3 方代码。 Windows 组件就是一个例子。这些通常不需要部署,您可以将它们视为已经就位。有时情况并非如此,例如 Windows 2000 上的 GDI+。
有时您会静态链接到第 3 方代码(同样简单),但如果您动态链接,则意味着部署要求。
The correct answer to this question, in my view, is to start at the source rather than to reverse engineer the solution with Dependency Walker, awesome and useful tool though it undoubtedly is.
The problem with Dependency Walker is that it only tells you what one particular run of the program requires on the OS on which you run it. If you have any dynamic loading dependencies in your app then you would only pick those up if you made sure you profiled the app with Dep. Walker and forced it through those dynamic loads.
My preferred approach to this problem is to start with your own source code and analyse and understand what it depends upon. It's often easy enough to do so because you know it well.
You need to understand what are the deployment requirements for your compiler. You usually have options of linking statically and dynamically to the C++ runtime. Obviously a dynamic link results in a deployment requirement.
You will also likely link to 3rd party code. One example would be Windows components. These typically don't need deployment, you can take them as already being in place. Sometimes that's not true, e.g. GDI+ on Windows 2000.
Sometimes you will link statically to 3rd party code (again easy), but if you link dynamically then that implies a deployment requirement.