Can';是否在Windows上使用zlib依赖项编译?
我正在尝试用MSVC将一个使用zlib的程序移植到Windows。但不幸的是,经过数小时的尝试,我似乎无法运行任何引用zlib的操作 下面是我用来测试zlib是否可以运行的虚拟程序:Can';是否在Windows上使用zlib依赖项编译?,windows,dll,visual-c++,zlib,Windows,Dll,Visual C++,Zlib,我正在尝试用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;
#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;
}
然后,当我尝试运行test.exe时,会出现一个错误对话框,说明:
此应用程序无法启动
因为找不到zlib1.dll。
重新安装应用程序可能会修复
这个问题
非常感谢您的帮助。zlib1.dll需要位于路径中或与可执行文件位于同一目录中。听起来您在GnuWin32目录中有
zlib1.dll
?识别zlib1.dll
的最简单方法可能是将其复制到与test.exe
相同的目录中。您还可以下载一个名为的免费工具,以更好地了解为什么找不到zlib1.dll
。您应该阅读Win32目录中ZLIB发行版附带的dll_FAQ.txt文件。它解释了为什么他们使用ZLIB1.dll而不是ZLIB.dll,为什么要进行更改,差异是什么,并让您深入了解可以做出的选择 您应该将这些文件(zconf.h和zlib.h)复制到qt安装文件夹的MSVC/include/文件夹中
例如,此文件应存在:
C:\Qt\Qt5.14.2\5.14.2\msvc2017\u 64\include\QtZlib\zlib.h
C:\Qt\Qt5.14.2\5.14.2\msvc2017\u 64\include\QtZlib\zconf.h
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"