在zlib.net下载zlib-1.2.12后,使用visual studio 2019 community打开xxx/zlib-1.2.12/contrib/vstudio/vc14/zlibvc.sln中,进行编译,过程中出现的问题如下。
问题1.没有bld_ml32.bat
编译器报错详情:1>d:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(145,5): error MSB3073: 命令“cd ..\..\masmx86
1>d:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(145,5): error MSB3073: bld_ml32.bat
1>d:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(145,5): error MSB3073: :VCEnd”已退出,代码为 9009。
问题解决:查看contrib目录下,确实没有masmx86,拷贝zlib-1.2.11中的masmx76到contrib目录下,问题解决。
问题2.实参的字节长度不同于以前的调用或引用
编译器报错详情如下:
1>F:\MyExercise\vs2019\zlib-1.2.12\crc32.c(1089,27): error C2708: “crc32_combine64”: 实参的字节长度不同于以前的调用或引用
1>F:\MyExercise\vs2019\zlib-1.2.12\crc32.c(1072): message : 参见“crc32_combine64”的声明
1>F:\MyExercise\vs2019\zlib-1.2.12\crc32.c(1106,31): error C2708: “crc32_combine_gen64”: 实参的字节长度不同于以前的调用或引用
1>F:\MyExercise\vs2019\zlib-1.2.12\crc32.c(1093): message : 参见“crc32_combine_gen64”的声明
1>F:\MyExercise\vs2019\zlib-1.2.12\crc32.c(1110,7): error C2373: “crc32_combine_op”: 重定义;不同的类型修饰符
1>F:\MyExercise\vs2019\zlib-1.2.12\zlib.h(1768): message : 参见“crc32_combine_op”的声明
1>deflate.c
问题解决:在crc32.c中修改如下内容
1.修改函数uLong ZEXPORT crc32_combine(crc1, crc2, len2)
uLong crc1;
uLong crc2;
z_off_t len2;为z_off64_t len2;
2.修改函数:1.uLong ZEXPORT crc32_combine_gen(len2)
z_off_t len2;为z_off64_t len2
3.修改:uLong crc32_combine_op(crc1, crc2, op)为uLong crc32_combine_op(crc1, crc2, op)为uLong ZEXPORT crc32_combine_op(crc1, crc2, op)为uLong crc32_combine_op(crc1, crc2, op)
问题3:模块对于 SAFESEH 映像是不安全的。
使用Release编译,忽略其他编译警告,编译通过。
当使用Debug编译时,出现
1> Assembling: inffas32.asm
1>match686.obj : error LNK2026: 模块对于 SAFESEH 映像是不安全的。
1>inffas32.obj : error LNK2026: 模块对于 SAFESEH 映像是不安全的。
1> 正在创建库 x86\ZlibDllDebug\zlibwapi.lib 和对象 x86\ZlibDllDebug\zlibwapi.exp
1>x86\ZlibDllDebug\zlibwapi.dll : fatal error LNK1281: 无法生成 SAFESEH 映像。
按照网上的教程,解决方式如下