我正在尝试将使用zlib的程序移植到使用MSVC的Windows。不幸的是,经过几个小时的尝试后,我似乎无法获得任何引用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档案的内容安装的zlib后发现here到各自的GnuWin32目录(如设置程序中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。 重新安装应用程序可能会修复 此问题。
任何帮助将非常感激。