如何在macOS上编译修复zipnote问题的Info-Zip?
问题:zipnote重命名Zip文件失败与源码编译类型冲突错误
一、zipnote重命名错误
使用zipnote重命名Zip文件时执行以下命令:
$ echo -e "@ -\n@=newname.sql" | zipnote -w file.zip zipnote error: Bad file descriptor zipnote error: Temporary file failure (zisC9HAb
出现上述错误。
二、已知修复方案
该问题已在Zip 3.1b beta版本中修复,可使用对应补丁解决。
三、源码编译遇到的类型冲突错误
尝试从源码编译Info-Zip,执行make -f unix/Makefile generic命令时,出现error: conflicting types for 'memset'/'memcpy'/'memcmp'错误,关键日志如下:
$ make -f unix/Makefile generic ... eval /Applications/Xcode.app/Contents/Developer/usr/bin/make -f unix/Makefile zips `cat flags` cc -c -I. -DUNIX -O3 -DBZIP2_SUPPORT -DUIDGID_NOT_16BIT -DLARGE_FILE_SUPPORT -DUNICODE_SUPPORT -DNO_RMDIR -DNO_STRCHR -DNO_STRRCHR -DNO_RENAME -DNO_MKTEMP -DNO_MKTIME -DNO_MKSTEMP -DZMEM -DNO_ERRNO -DNO_DIR -DHAVE_DIRENT_H -DHAVE_TERMIOS_H -DNO_VALLOC zip.c In file included from zip.c:16: ./zip.h:726:10: error: conflicting types for 'memset' 726 | char *memset OF((char *, int, unsigned int)); | ^ /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/_string.h:74:7: note: previous declaration is here 74 | void *memset(void *__b, int __c, size_t __len); | ^ In file included from zip.c:16: ./zip.h:727:10: error: conflicting types for 'memcpy' 727 | char *memcpy OF((char *, char *, unsigned int)); | ^ /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/_string.h:72:7: note: previous declaration is here 72 | void *memcpy(void *__dst, const void *__src, size_t __n); | ^ In file included from zip.c:16: ./zip.h:728:8: error: conflicting types for 'memcmp' 728 | int memcmp OF((char *, char *, unsigned int)); | ^ ...
四、操作步骤
4.1 代码目录准备
# 下载zip30源码 $ curl -fsSL ftp://ftp.info-zip.org/pub/infozip/src/zip30.zip | bsdtar xzf - -C /tmp/ # 下载补丁到指定路径 $ curl -o /tmp/zipinfo.patch -fsSL [补丁获取地址] # 应用补丁 $ cd /tmp/zip30 $ patch -u zipnote.c -i ../zipinfo.patch
4.2 源码编译
执行以下命令触发错误:
$ make -f unix/Makefile generic
五、macOS环境信息
$ sw_vers ProductName: macOS ProductVersion: 14.7.2 BuildVersion: 23H311 $ uname -a Darwin iMarslo 23.6.0 Darwin Kernel Version 23.6.0: Fri Nov 15 15:12:37 PST 2024; root:xnu-10063.141.1.702.7~1/RELEASE_ARM64_T6030 arm64 arm Darwin $ xcodebuild -version Xcode 16.1 Build version 16B40 $ llvm-config --version 19.1.5
六、额外问题:如何使用系统默认LLVM编译器编译
系统默认zip由Apple LLVM编译,版本信息如下:
$ which -a zip /usr/bin/zip $ /usr/bin/zip --version ... Compiled with gcc Apple LLVM 15.0.0 (clang-1500.3.9.1) [+internal-os] for Unix (Mac OS X) on Jul 19 2024.
如何使用相同的编译器编译自己的Info-Zip版本?
内容的提问来源于stack exchange,提问作者Marslo
相关产品推荐
相关产品推荐

