【发布时间】:2009-12-17 03:56:31
【问题描述】:
我正在尝试通过 MSVC 将使用 zlib 的程序移植到 Windows。不幸的是,经过几个小时的尝试,我似乎无法让任何引用 zlib 的东西运行。
这是我用来测试 zlib 是否可以运行的虚拟程序:
#include <zlib.h>
#include <stdio.h>
int main(void)
{
z_stream zst;
zst.zalloc = Z_NULL;
zst.zfree = Z_NULL;
zst.opaque = Z_NULL;
zst.next_out = Z_NULL;
zst.next_in = Z_NULL;
zst.avail_out = 0;
inflateInit(&zst);
puts("hello, world!");
return 0;
}
通过将找到的 zlib DLL 归档文件的内容复制到它们各自的 GnuWin32 目录中来安装 zlib 后 here (因为发现 here 的设置似乎包含无效的标头),我尝试使用以下内容编译测试程序:
C:\Documents and Settings\Administrator\My Documents>cl test.c -I"C:\Program Files\GnuWin32\include" "C:\Program Files\GnuWin32\lib\zlib.lib"
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 15.00.30729.0 for 80x86
Copyright (C) Microsoft Corporation. All rights reserved
test.c
Microsoft (R) Incremental Linker Version 9.0030729.01
Copyright (C) Microsoft Corporation. All rights reserved.
/out:test.exe
test.obj
"C:\Program Files\GnuWin32\lib/zlib.lib"
然后,当我尝试运行 test.exe 时,我收到一个错误对话框:
此应用程序启动失败 因为没有找到 zlib1.dll。 重新安装应用程序可能会修复 这个问题。
非常感谢任何帮助。
【问题讨论】:
标签: windows dll visual-c++ zlib