我正在尝试通过 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 后(因为此处找到的设置似乎包含无效的标头),我尝试使用以下内容编译测试程序:
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。重新安装应用程序可能会解决此问题。
任何帮助将不胜感激。