报错1:
标准不同
cc -g -O2 -I. -I./LZMA/lzma465/C -I./LZMA/lzmalt -I./LZMA/lzmadaptive/C/7zip/Compress/LZMA_Lib -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_GNU_SOURCE -DCOMP_DEFAULT=\"gzip\" -Wall -Werror -DGZIP_SUPPORT -DLZMA_SUPPORT -DXZ_SUPPORT -DLZO_SUPPORT -DXATTR_SUPPORT -DXATTR_DEFAULT -c -o unsquashfs.o unsquashfs.c
unsquashfs.c: In function ‘read_super’:
unsquashfs.c:1835:5: error: this ‘if’ clause does not guard... [-Werror=misleading-indentation]
1835 | if(swap)
| ^~
unsquashfs.c:1841:9: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘if’
1841 | read_fs_bytes(fd, SQUASHFS_START, sizeof(struct squashfs_super_block),
| ^~~~~~~~~~~~~
cc1: all warnings being treated as errors
解决方法:
在unsquashfs.c文件第1835行下加上大括号,如下:
报错2:
链接找不到符号
p.o compressor.o unsquashfs_info.o gzip_wrapper.o lzma_wrapper.o ./LZMA/lzma465/C/Alloc.o ./LZMA/lzma465/C/LzFind.o ./LZMA/lzma465/C/LzmaDec.o ./LZMA/lzma465/C/LzmaEnc.o ./LZMA/lzma465/C/LzmaLib.o xz_wrapper.o lzo_wrapper.o read_xattrs.o unsquashfs_xattr.o -lpthread -lm -lz -L./LZMA/lzmadaptive/C/7zip/Compress/LZMA_Lib -llzmalib -llzma -llzo2 -o sasquatch
/usr/bin/ld: unsquashfs.o: in function `read_fs_bytes':
/tmp/sasquatch/squashfs4.3/squashfs-tools/unsquashfs.c:638: undefined reference to `verbose'
/usr/bin/ld: /tmp/sasquatch/squashfs4.3/squashfs-tools/unsquashfs.c:638: undefined reference to `verbose'
/usr/bin/ld: unsquashfs.o: in function `read_block':
/tmp/sasquatch/squashfs4.3/squashfs-tools/unsquashfs.c:681: undefined reference to `verbose'
/usr/bin/ld: /tmp/sasquatch/squashfs4.3/squashfs-tools/unsquashfs.c:681: undefined reference to `verbose'
/usr/bin/ld: unsquashfs.o: in function `read_data_block':
/tmp/sasquatch/squashfs4.3/squashfs-tools/unsquashfs.c:749: undefined reference to `verbose'
/usr/bin/ld: unsquashfs.o:/tmp/sasquatch/squashfs4.3/squashfs-tools/unsquashfs.c:749: more undefined references to `verbose' follow
collect2: error: ld returned 1 exit status
在error.h里 #include
下面加上extern int verbose
同时在 unsquashfs.c 里加上int verbose = 0
,别塞到函数里就行
改完,应该能顺利编译。