Qt5.15.0 升级至 Qt5.15.9 遇到的一些错误

Posted 一叶扁舟

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Qt5.15.0 升级至 Qt5.15.9 遇到的一些错误相关的知识,希望对你有一定的参考价值。

按照之前我写的文章教程,可以很简单的编译出静态库(仅供学习交流)

编译出静态库后,替换旧版本的库,见我另一篇文章教程

之所以没有直接上 Qt6.0 以上的版本,是因为 Qt6.0 对比 Qt5 删减了不少东西(我之前已经测试过了),这就导致项目要有比较大的改动,所以暂时没有特别要换的需求

Qt5.15.9 的静态库版本是今年四月份(2023.4.6)官方才放出的,修复了不少 bug,其中包括我之前遇到的一个字体 bug,见下面的文章,

在编译项目时,遇到了两个比较棘手的问题,第一个是库中函数重定义问题,第二个是找不到对应的库

下面说说这两个问题的解决方法,

第一个报错

1>zlibd.lib(crc32.obj) : error LNK2005: _crc32_combine_op already defined in Qt5Cored.lib(crc32.obj)
1>zlibd.lib(crc32.obj) : error LNK2005: _crc32_combine_gen already defined in Qt5Cored.lib(crc32.obj)
1>zlibd.lib(crc32.obj) : error LNK2005: _crc32_combine_gen64 already defined in Qt5Cored.lib(crc32.obj)
1>******************************************** : fatal error LNK1169: one or more multiply defined symbols found

因为这两个库我都要用到,所以就使用 /FORCE:MULTIPLE  强行忽略第二个定义

结果,

zlibd.lib(crc32.obj) : warning LNK4006: _crc32_combine_op already defined in Qt5Cored.lib(crc32.obj); second definition ignored
1>zlibd.lib(crc32.obj) : warning LNK4006: _crc32_combine_gen already defined in Qt5Cored.lib(crc32.obj); second definition ignored
1>zlibd.lib(crc32.obj) : warning LNK4006: _crc32_combine_gen64 already defined in Qt5Cored.lib(crc32.obj); second definition ignored

第二个报错

qjpegd.lib(qjpeghandler.obj) : error LNK2019: unresolved external symbol _jpeg_std_error referenced in function "bool __cdecl do_write_jpeg_image(struct jpeg_compress_struct &,unsigned char * *,class QImage const &,class QIODevice *,int,class QString const &,bool,bool)" (?do_write_jpeg_image@@YA_NAAUjpeg_compress_struct@@PAPAEABVQImage@@PAVQIODevice@@HABVQString@@_N5@Z)
1>qjpegd.lib(qjpeghandler.obj) : error LNK2019: unresolved external symbol _jpeg_CreateCompress referenced in function "bool __cdecl do_write_jpeg_image(struct jpeg_compress_struct &,unsigned char * *,class QImage const &,class QIODevice *,int,class QString const &,bool,bool)" (?do_write_jpeg_image@@YA_NAAUjpeg_compress_struct@@PAPAEABVQImage@@PAVQIODevice@@HABVQString@@_N5@Z)
1>qjpegd.lib(qjpeghandler.obj) : error LNK2019: unresolved external symbol _jpeg_CreateDecompress referenced in function "public: bool __thiscall QJpegHandlerPrivate::readJpegHeader(class QIODevice *)" (?readJpegHeader@QJpegHandlerPrivate@@QAE_NPAVQIODevice@@@Z)
1>qjpegd.lib(qjpeghandler.obj) : error LNK2019: unresolved external symbol _jpeg_destroy_compress referenced in function "bool __cdecl do_write_jpeg_image(struct jpeg_compress_struct &,unsigned char * *,class QImage const &,class QIODevice *,int,class QString const &,bool,bool)" (?do_write_jpeg_image@@YA_NAAUjpeg_compress_struct@@PAPAEABVQImage@@PAVQIODevice@@HABVQString@@_N5@Z)
1>qjpegd.lib(qjpeghandler.obj) : error LNK2019: unresolved external symbol _jpeg_destroy_decompress referenced in function "public: __thiscall QJpegHandlerPrivate::~QJpegHandlerPrivate(void)" (??1QJpegHandlerPrivate@@QAE@XZ)
1>qjpegd.lib(qjpeghandler.obj) : error LNK2019: unresolved external symbol _jpeg_set_defaults referenced in function "bool __cdecl do_write_jpeg_image(struct jpeg_compress_struct &,unsigned char * *,class QImage const &,class QIODevice *,int,class QString const &,bool,bool)" (?do_write_jpeg_image@@YA_NAAUjpeg_compress_struct@@PAPAEABVQImage@@PAVQIODevice@@HABVQString@@_N5@Z)
1>qjpegd.lib(qjpeghandler.obj) : error LNK2019: unresolved external symbol _jpeg_set_quality referenced in function "bool __cdecl do_write_jpeg_image(struct jpeg_compress_struct &,unsigned char * *,class QImage const &,class QIODevice *,int,class QString const &,bool,bool)" (?do_write_jpeg_image@@YA_NAAUjpeg_compress_struct@@PAPAEABVQImage@@PAVQIODevice@@HABVQString@@_N5@Z)
1>qjpegd.lib(qjpeghandler.obj) : error LNK2019: unresolved external symbol _jpeg_simple_progression referenced in function "bool __cdecl do_write_jpeg_image(struct jpeg_compress_struct &,unsigned char * *,class QImage const &,class QIODevice *,int,class QString const &,bool,bool)" (?do_write_jpeg_image@@YA_NAAUjpeg_compress_struct@@PAPAEABVQImage@@PAVQIODevice@@HABVQString@@_N5@Z)
1>qjpegd.lib(qjpeghandler.obj) : error LNK2019: unresolved external symbol _jpeg_start_compress referenced in function "bool __cdecl do_write_jpeg_image(struct jpeg_compress_struct &,unsigned char * *,class QImage const &,class QIODevice *,int,class QString const &,bool,bool)" (?do_write_jpeg_image@@YA_NAAUjpeg_compress_struct@@PAPAEABVQImage@@PAVQIODevice@@HABVQString@@_N5@Z)
1>qjpegd.lib(qjpeghandler.obj) : error LNK2019: unresolved external symbol _jpeg_write_scanlines referenced in function "bool __cdecl do_write_jpeg_image(struct jpeg_compress_struct &,unsigned char * *,class QImage const &,class QIODevice *,int,class QString const &,bool,bool)" (?do_write_jpeg_image@@YA_NAAUjpeg_compress_struct@@PAPAEABVQImage@@PAVQIODevice@@HABVQString@@_N5@Z)
1>qjpegd.lib(qjpeghandler.obj) : error LNK2019: unresolved external symbol _jpeg_finish_compress referenced in function "bool __cdecl do_write_jpeg_image(struct jpeg_compress_struct &,unsigned char * *,class QImage const &,class QIODevice *,int,class QString const &,bool,bool)" (?do_write_jpeg_image@@YA_NAAUjpeg_compress_struct@@PAPAEABVQImage@@PAVQIODevice@@HABVQString@@_N5@Z)
1>qjpegd.lib(qjpeghandler.obj) : error LNK2019: unresolved external symbol _jpeg_write_marker referenced in function "void __cdecl set_text(class QImage const &,struct jpeg_compress_struct *,class QString const &)" (?set_text@@YAXABVQImage@@PAUjpeg_compress_struct@@ABVQString@@@Z)
1>qjpegd.lib(qjpeghandler.obj) : error LNK2019: unresolved external symbol _jpeg_read_header referenced in function "public: bool __thiscall QJpegHandlerPrivate::readJpegHeader(class QIODevice *)" (?readJpegHeader@QJpegHandlerPrivate@@QAE_NPAVQIODevice@@@Z)
1>qjpegd.lib(qjpeghandler.obj) : error LNK2019: unresolved external symbol _jpeg_start_decompress referenced in function "bool __cdecl read_jpeg_image(class QImage *,class QSize,class QRect,class QRect,int,void (__fastcall*)(unsigned int *,unsigned char const *,int),struct jpeg_decompress_struct *,struct my_error_mgr *)" (?read_jpeg_image@@YA_NPAVQImage@@VQSize@@VQRect@@2HP6IXPAIPBEH@ZPAUjpeg_decompress_struct@@PAUmy_error_mgr@@@Z)
1>qjpegd.lib(qjpeghandler.obj) : error LNK2019: unresolved external symbol _jpeg_read_scanlines referenced in function "bool __cdecl read_jpeg_image(class QImage *,class QSize,class QRect,class QRect,int,void (__fastcall*)(unsigned int *,unsigned char const *,int),struct jpeg_decompress_struct *,struct my_error_mgr *)" (?read_jpeg_image@@YA_NPAVQImage@@VQSize@@VQRect@@2HP6IXPAIPBEH@ZPAUjpeg_decompress_struct@@PAUmy_error_mgr@@@Z)
1>qjpegd.lib(qjpeghandler.obj) : error LNK2019: unresolved external symbol _jpeg_finish_decompress referenced in function "bool __cdecl read_jpeg_image(class QImage *,class QSize,class QRect,class QRect,int,void (__fastcall*)(unsigned int *,unsigned char const *,int),struct jpeg_decompress_struct *,struct my_error_mgr *)" (?read_jpeg_image@@YA_NPAVQImage@@VQSize@@VQRect@@2HP6IXPAIPBEH@ZPAUjpeg_decompress_struct@@PAUmy_error_mgr@@@Z)
1>qjpegd.lib(qjpeghandler.obj) : error LNK2019: unresolved external symbol _jpeg_calc_output_dimensions referenced in function "bool __cdecl read_jpeg_size(int &,int &,struct jpeg_decompress_struct *)" (?read_jpeg_size@@YA_NAAH0PAUjpeg_decompress_struct@@@Z)
1>qjpegd.lib(qjpeghandler.obj) : error LNK2019: unresolved external symbol _jpeg_save_markers referenced in function "public: bool __thiscall QJpegHandlerPrivate::readJpegHeader(class QIODevice *)" (?readJpegHeader@QJpegHandlerPrivate@@QAE_NPAVQIODevice@@@Z)
1>qjpegd.lib(qjpeghandler.obj) : error LNK2019: unresolved external symbol _jpeg_resync_to_restart referenced in function "public: __thiscall my_jpeg_source_mgr::my_jpeg_source_mgr(class QIODevice *)" (??0my_jpeg_source_mgr@@QAE@PAVQIODevice@@@Z)

LNK2019 的报错很简单明了,就是链接时没有找到对应函数的符号文件,导致链接失败,然后报错

结合新生成的 lib 文件,我第一感觉就是 Qt5.15.9 将这些函数删减了

lib 文件大小删减了三分之二左右,故项目中原先依赖这块部分的函数都找不到符号文件了

目前我的解决方案是将项目中这块依赖代码删掉(这些代码用于 jpeg 的图片插件),后续测试看看有没有问题,先保证项目能编译成功

这两个错误解决后,项目再次 0 error,并且字体 bug 不出现了

QT学习_QT远程文件升级

QT文档升级

首先写配置文件:

[update]
filename = "D:\\\\lesliex\\\\QTpro\\\\UpdatePro\\\\testupdatefile\\\\file";
checkname = "file";

代码

选择已更新的文件夹

void MainWindow::on_pushButton_clicked()
{
   updateDir = QFileDialog::getExistingDirectory(this,"select Dir",QDir::currentPath());
    
   ui->plainTextEdit->appendPlainText("ready update...");
}

进行升级

void MainWindow::on_pushButton_2_clicked()
{
    //读取配置文件
    QSettings setting("..\\\\setting.ini",QSettings::IniFormat,this);
    QString readyupdateDir = setting.value("/update/filename").toString();
    QString checkName = setting.value("/update/checkname").toString();
	
    //进行升级
    QFileInfo fileInfo(readyupdateDir);
    if(fileInfo.isDir()){
        if(fileInfo.fileName() == checkName){
            ui->plainTextEdit->appendPlainText("copying...");
            copyToDir(updateDir,readyupdateDir);
            ui->plainTextEdit->appendPlainText("update success!");
        }
        else
        ui->plainTextEdit->appendPlainText("update error!");
    }else
        ui->plainTextEdit->appendPlainText("update error!");

}

文件夹覆盖操作

void MainWindow::copyToDir(QString FromDir, QString ToDir)
{
    //获取两个文件夹
    QDir sourceDir(FromDir);
    QDir targetDir(ToDir);

    //若目标文件不存在则创建
    if(!targetDir.exists()) targetDir.mkdir(targetDir.absolutePath());

    //获取源文件夹中文件信息
    QFileInfoList sourceFileInfos = sourceDir.entryInfoList();

    //逐个判别文件采取对应策略,注意QFileInfo类fileName和filePath的区别
    for(auto i : sourceFileInfos){
        //跳过"."".."文件
        if(i.fileName()=="." || i.fileName()=="..") continue;
        //如果是文件夹,则递归
        else if(i.isDir()){
            copyToDir(i.filePath(),targetDir.filePath(i.fileName()));
        }
        //如果是文件,如果文件存在则先删除,再复制
        else if(i.isFile()){
            if(targetDir.exists(i.fileName()))targetDir.remove(i.fileName());
            QFile::copy(i.filePath(),targetDir.filePath(i.fileName()));
        }
    }
}

后续可扩展:解压缩包升级,网络远程升级

以上是关于Qt5.15.0 升级至 Qt5.15.9 遇到的一些错误的主要内容,如果未能解决你的问题,请参考以下文章

补丁版本 LTS Qt 5.15.9 商业版发布

php5.4 升级至php5.6遇到到问题

CentOS升级OpenSSL至OpenSSL 1.1.0f版本<其中有遇到libcrypto.so

centOS升级python2至python3过程中遇到configure: error: no acceptable C compiler found in $PATH

医学四视图-006-升级Vtk版本至9.0.3

Spotify是怎样从Postgres切换至Cassandra的?