按照之前我写的文章教程,可以很简单的编译出静态库(仅供学习交流)
编译出静态库后,替换旧版本的库,见我另一篇文章教程
之所以没有直接上 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 不出现了
标签:Qt5.15,obj,struct,错误,jpeg,升级,bool,lib,class From: https://www.cnblogs.com/strive-sun/p/17325948.html