c++ - 将 QuaZip 添加到项目中
问题描述
我正在尝试将 QuaZip 添加到我的项目中,但出现构建错误,所有这些都与未定义的引用有关。这是第一个错误,它们主要与 extractAll 函数中的存档函数有关。
错误:未定义对 `_imp___ZN6QuaZip13goToFirstFileEv' 的引用
这是对我的 .pro 文件的补充:
INCLUDEPATH += $$PWD/quazip/
LIBS += -L$$PWD/libs/
INCLUDEPATH += $$PWD/zlib/include/
INCLUDEPATH += $$PWD/zlib/lib/
LIBS += -L$$PWD/zlib/lib/
在 quazip 子文件夹中,我有 quazip 的所有标题。在 libs 文件夹中的那一行中,我有 .a 用于 quazip。zilib 子文件夹包含 zlib 开发人员文件。
这是我正在尝试使用的功能:
void Utilities::updateFiles_zip()
{
currentDownloads.clear();
init_files();
QString error = "";
QString file = "LAE-Intnl-numbers-new.zip";
error = checkForUpdates(file);
if (error != "")
{
errorMessage = error;
if (DEBUG)
qDebug() << "error = {" << error << "}";
return;
}
QString filename = downloadPath + "LAE-Intnl-numbers-new.zip";
QuaZip *zip_file = new QuaZip(filename);
extractAll(zip_file, inputPath);
}
void Utilities::extractAll( QuaZip *archive, QString destFileFolder )
{
// extracts all files from the archive and saves
// them onto disk
//
// just a simple implementation for evaluation.
// error handling has not been implemented yet!
for( bool f = archive->goToFirstFile(); f; f = archive->goToNextFile() )
{
// set source file in archive
QString filePath = archive->getCurrentFileName();
QuaZipFile zFile( archive->getZipName(), filePath );
// open the source file
zFile.open( QIODevice::ReadOnly );
// create a bytes array and write the file data into it
QByteArray ba = zFile.readAll();
// close the source file
zFile.close();
// set destination file
QString destFilePath = destFileFolder + filePath;
QFile dstFile( destFilePath );
// open the destination file
dstFile.open( QIODevice::WriteOnly | QIODevice::Text );
// write the data from the bytes array into the destination file
dstFile.write( ba.data() );
//close the destination file
dstFile.close();
}
}
编辑:得到它遵守,但应用程序现在崩溃了。
这是我的 .pro 文件的外观:
#-------------------------------------------------
#
# Project created by QtCreator 2013-04-20T05:16:50
#
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = Lottery
TEMPLATE = app
INCLUDEPATH += $$PWD/zlib/include
INCLUDEPATH += $$PWD/zlib/lib
LIBS += -L$$PWD/zlib/lib
LIBS += -L$$PWD/libs/ -lquazip
SOURCES += main.cpp \
mainwindow.cpp \
Games.cpp \
Config.cpp \
ProcessNumbers.cpp \
SortMethods.cpp \
Headers.cpp \
AnalysisMethods.cpp \
CombosMethods.cpp \
CheckMatchesMethods.cpp \
MatchesMethods.cpp \
RandomMethods.cpp \
form.cpp \
Utilities.cpp \
numbersranksavgsdiffs.cpp \
MatchesMethods_LM.cpp
HEADERS += mainwindow.h \
AnalysisMethods.h \
Config.h \
Headers.h \
ProcessNumbers.h \
SortMethods.h \
dates.h \
sorts.h \
update.h \
Games.h \
CombosMethods.h \
combos.h \
gameballs.h \
comboscheck.h \
CheckMatchesMethods.h \
MatchesMethods.h \
RandomMethods.h \
checkmatches.h \
progress.h \
form2.h \
matches.h \
random.h \
Utilities.h \
pointers.h \
diffs.h \
numbersranksavgsdiffs.h \
MatchesMethods_LM.h \
matches_lm.h \
analysis.h
include(quazip.pri)
FORMS += \
mainwindow.ui \
dates.ui \
update.ui \
sorts.ui \
combos.ui \
gameballs.ui \
comboscheck.ui \
checkmatches.ui \
form2.ui \
progress.ui \
matches.ui \
random.ui \
diffs.ui \
matches_lm.ui \
analysis.ui
QT += network
QT += core gui widgets
QT += concurrent
#QMAKE_LFLAGS_WINDOWS += -Wl,--stack,32000000
#QMAKE_LFLAGS += /STACK:32000000
#QMAKE_LFLAGS_WINDOWS = /SUBSYSTEM:WINDOWS,5.01
RC_ICONS = currency_blue_dollar.ico
这是我的 quazip.pri 外观:
#INCLUDEPATH += $$PWD/quazip
#DEPENDPATH += $$PWD/quazip
INCLUDEPATH += $$PWD/quazip/headers
HEADERS += $$PWD/quazip/headers/minizip_crypt.h \
$$PWD/quazip/headers/ioapi.h \
$$PWD/quazip/headers/JlCompress.h \
$$PWD/quazip/headers/quaadler32.h \
$$PWD/quazip/headers/quachecksum32.h \
$$PWD/quazip/headers/quacrc32.h \
$$PWD/quazip/headers/quagzipfile.h \
$$PWD/quazip/headers/quaziodevice.h \
$$PWD/quazip/headers/quazipdir.h \
$$PWD/quazip/headers/quazipfile.h \
$$PWD/quazip/headers/quazipfileinfo.h \
$$PWD/quazip/headers/quazip_global.h \
$$PWD/quazip/headers/quazip.h \
$$PWD/quazip/headers/quazipnewinfo.h \
$$PWD/quazip/headers/unzip.h \
$$PWD/quazip/headers/zip.h
# $$PWD/zlib/include/zlib.h
#SOURCES += $$PWD/quazip/qioapi.cpp \
# $$PWD/quazip/JlCompress.cpp \
# $$PWD/quazip/quaadler32.cpp \
# $$PWD/quazip/quacrc32.cpp \
# $$PWD/quazip/quagzipfile.cpp \
# $$PWD/quazip/quaziodevice.cpp \
# $$PWD/quazip/quazip.cpp \
# $$PWD/quazip/quazipdir.cpp \
# $$PWD/quazip/quazipfile.cpp \
# $$PWD/quazip/quazipfileinfo.cpp \
# $$PWD/quazip/quazipnewinfo.cpp \
# $$PWD/quazip/unzip.c \
# $$PWD/quazip/zip.c
解决方案
为什么不将源代码放在您喜欢的任何目录中。例如,第 3 方:
|-- project.pro
|-- ....
|-- 3rdparty\
| |-- QuaZip\
| |
将以下行添加到您的 qmake 项目文件中:
include(3rdparty/quazip/blob/master/quazip.pri)
并将qmake
完成这项工作
推荐阅读
- json - 解析从 Django 异步休息调用返回的 json
- imap - IMAP 邮件转发和组织建议?
- java - Maven Spring Boot 尝试连接到 MySQL
- laravel - 如何从 Laravel 查询对 ajax 结果的分页 api 进行迭代?
- python - 如果 conda 包最初安装在 Windows 上,我如何在 Linux 上安装它们?
- python - 无法在 Django 3 中对自定义用户进行身份验证
- swift - Swift - AVAssetExportSession exportSession.exportAsynchronously 完成处理程序未调用
- php - 有没有办法从变体选择下拉 woocommerce 中取消设置/删除缺货变体?
- jsx - 从 CRA 弹出后“您可能需要适当的加载程序来处理此文件类型”
- ruby-on-rails - 使用 Rails 如何在给定时间段内查找用户预订的课程