在windows 8.1和qt creator下编译quazip

Compile quazip under windows 8.1 and qt creator

我是新手,正在尝试在 qt 5.5 下使用 Quazip。所以我刚刚从 http://quazip.sourceforge.net/ 下载了项目源并打开了 .pro 文件。当我尝试构建项目时出现多个错误:

C1083: Cannot open include file: 'zlib.h': No such file or directory

为了避免在 windows 上构建 zlib,我刚刚在 C:\GnuWin32 中安装了(从这里:http://gnuwin32.sourceforge.net/packages/zlib.htm)windows 的完整包。然后我在 .pro 文件中添加了这一行:

INCLUDEPATH += C:\GnuWin32\include

这产生了另一个错误:

Cannot open include file: 'unistd.h': No such file or directory

但是改变这一行

#if 1           /* HAVE_UNISTD_H -- this line is updated by ./configure */

解决了这个问题。

#if HAVE_UNISTD_H

不幸的是,现在我得到 25 个未解析的外部符号,其中一些是:

quaadler32.obj:-1: error: LNK2019: unresolved external symbol adler32 referenced in function "public: virtual unsigned int __cdecl QuaAdler32::calculate(class QByteArray const &)" (?calculate@QuaAdler32@@UEAAIAEBVQByteArray@@@Z)
quacrc32.obj:-1: error: LNK2019: unresolved external symbol crc32 referenced in function "public: virtual unsigned int __cdecl QuaCrc32::calculate(class QByteArray const &)" (?calculate@QuaCrc32@@UEAAIAEBVQByteArray@@@Z)
unzip.obj:-1: error: LNK2001: unresolved external symbol crc32
quagzipfile.obj:-1: error: LNK2019: unresolved external symbol gzopen referenced in function "private: void * __cdecl QuaGzipFilePrivate::open(class QString const &,char const *)" (?open@QuaGzipFilePrivate@@AEAAPEAXAEBVQString@@PEBD@Z)
quaziodevice.obj:-1: error: LNK2019: unresolved external symbol deflateInit_ referenced in function "public: virtual bool __cdecl QuaZIODevice::open(class QFlags<enum QIODevice::OpenModeFlag>)" (?open@QuaZIODevice@@UEAA_NV?$QFlags@W4OpenModeFlag@QIODevice@@@@@Z)
quaziodevice.obj:-1: error: LNK2019: unresolved external symbol inflate referenced in function "protected: virtual __int64 __cdecl QuaZIODevice::readData(char *,__int64)" (?readData@QuaZIODevice@@MEAA_JPEAD_J@Z)

我尝试添加这一行:

LIBS += -LC:\GnuWin32\lib

但这并没有解决问题。在 Qt 下使用 Quazip 最简单的方法是什么?

  1. quzip site
  2. 下载 quazip 源
  3. 通过 Qt Creator 打开 quazip.pri
  4. 替换所有字符串 #include "zlib.h" 或“#include < zlib.h>”

#include <QtZlib/zlib.h>
  1. 构建项目和运行单元测试。