我的项目要求我在Windows和Mac上都使用C ++的解压缩功能。我尝试了一个来自互联网的源代码,其中包括zlib库我不确定这是否适用于Mac),但是我收到很多链接错误。
1>------ Build started: Project: ZipFile, Configuration: Debug Win32 ------
1> zipper.cpp
1> ZipFile.cpp
1> unzipper.cpp
1> stdafx.cpp
1> Generating Code...
1>unzipper.obj : error LNK2019: unresolved external symbol _unzOpen64 referenced in function "public: bool __thiscall ziputils::unzipper::open(char const *)" (?open@unzipper@ziputils@@QAE_NPBD@Z)
1>unzipper.obj : error LNK2019: unresolved external symbol _unzClose referenced in function "public: void __thiscall ziputils::unzipper::close(void)" (?close@unzipper@ziputils@@QAEXXZ)
1>unzipper.obj : error LNK2019: unresolved external symbol _unzGetGlobalInfo64 referenced in function "private: void __thiscall ziputils::unzipper::readEntries(void)" (?readEntries@unzipper@ziputils@@AAEXXZ)
1>unzipper.obj : error LNK2019: unresolved external symbol _unzGoToNextFile referenced in function "private: void __thiscall ziputils::unzipper::readEntries(void)" (?readEntries@unzipper@ziputils@@AAEXXZ)
1>unzipper.obj : error LNK2019: unresolved external symbol _unzLocateFile referenced in function "public: bool __thiscall ziputils::unzipper::openEntry(char const *)" (?openEntry@unzipper@ziputils@@QAE_NPBD@Z)
1>unzipper.obj : error LNK2019: unresolved external symbol _unzGetCurrentFileInfo64 referenced in function "public: unsigned int __thiscall ziputils::unzipper::getEntrySize(void)" (?getEntrySize@unzipper@ziputils@@QAEIXZ)
1>unzipper.obj : error LNK2019: unresolved external symbol _unzOpenCurrentFile referenced in function "public: bool __thiscall ziputils::unzipper::openEntry(char const *)" (?openEntry@unzipper@ziputils@@QAE_NPBD@Z)
1>unzipper.obj : error LNK2019: unresolved external symbol _unzCloseCurrentFile referenced in function "public: void __thiscall ziputils::unzipper::closeEntry(void)" (?closeEntry@unzipper@ziputils@@QAEXXZ)
1>unzipper.obj : error LNK2019: unresolved external symbol _unzReadCurrentFile referenced in function "public: class ziputils::unzipper & __thiscall ziputils::unzipper::operator>>(class std::basic_ostream<char,struct std::char_traits<char> > &)" (??5unzipper@ziputils@@QAEAAV01@AAV?$basic_ostream@DU?$char_traits@D@std@@@std@@@Z)
1>zipper.obj : error LNK2019: unresolved external symbol _zipOpen64 referenced in function "public: bool __thiscall ziputils::zipper::open(char const *,bool)" (?open@zipper@ziputils@@QAE_NPBD_N@Z)
1>zipper.obj : error LNK2019: unresolved external symbol _zipOpenNewFileInZip referenced in function "public: bool __thiscall ziputils::zipper::addEntry(char const *)" (?addEntry@zipper@ziputils@@QAE_NPBD@Z)
1>zipper.obj : error LNK2019: unresolved external symbol _zipWriteInFileInZip referenced in function "public: class ziputils::zipper & __thiscall ziputils::zipper::operator<<(class std::basic_istream<char,struct std::char_traits<char> > &)" (??6zipper@ziputils@@QAEAAV01@AAV?$basic_istream@DU?$char_traits@D@std@@@std@@@Z)
1>zipper.obj : error LNK2019: unresolved external symbol _zipCloseFileInZip referenced in function "public: void __thiscall ziputils::zipper::closeEntry(void)" (?closeEntry@zipper@ziputils@@QAEXXZ)
1>zipper.obj : error LNK2019: unresolved external symbol _zipClose referenced in function "public: void __thiscall ziputils::zipper::close(void)" (?close@zipper@ziputils@@QAEXXZ)
1>c:\users\ashraya\documents\visual studio 2015\Projects\ZipFile\Debug\ZipFile.exe : fatal error LNK1120: 14 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
我已经在链接器中添加了为x86平台编译的zlib.lib和zlibstatic.lib(分别是发布模式) - >输入 - >附加依赖项
在链接器中添加了包含目录的路径 - &gt; General-&gt;其他库目录
在C / C ++中添加了相同的包含路径 - &gt; General-&gt;其他包含目录
我不确定我哪里出错了。我在互联网上阅读了其他帖子,发现我需要添加
#ifdef _WIN32
#define ZLIB_WINAPI
#endif
用于Windows。但我不确定代码是否会在Mac中编译,因为此标志对Mac无效。无论如何,添加标志并没有解决链接错误。错误似乎来自Minizip,但我无法解决它们。
有人可以帮忙吗?
非常感谢,提前。
Esash