home | list info | list archive | date index | thread index

Re: compiling 7z or p7zip source

I think that the read-me has an error in the instructions. This is a little long, but a lot shorter than it would be if I had included the incredible amount of output generated. I only did the first compile in step 2 to generate the 7zz binary. I guess the rest will have similar issues and I was not about to mess with the makefile(s) to attempt to correct the issues.

use: git clone -b p7zip22.00 https://github.com/p7zip-project/p7zip.git

instead of: git clone -b p7zip22.00 https://github.com/jinfeihan57/p7zip.git

I also had to install 'patchelf' in order for it to properly proceed.

There is at least one known issue if you use a newer version of gcc greater than 12, mine is 15

gcc --version
gcc (GCC) 15.2.1 20251211 (Red Hat 15.2.1-5)
Copyright (C) 2025 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


A few items failed as I followed the instructions. Much of it was based on warnings, the first being on an issue in LzmaEnc.c which is a know issue.  and the default compile :

git clone -b p7zip22.00  https://github.com/p7zip-project/p7zip.git
cd p7zip/CPP/7zip/Bundles/Alone2 && make -f makefile.gcc
sudo dnf install patchelf
make -f makefile.gcc

after the first error, I manually fixed the issue with a compiler flag for the dangling pointer as this was explicitly stated when I looked it up:

make -f makefile.gcc
cc -Wno-error=dangling-pointer -O2 -c -Wall -Wextra -Werror -DNDEBUG -D_REENTRANT -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fPIC  -o _o/LzmaEnc.o ../../../../C/LzmaEnc.c

Next error:

make -f makefile.gcc
g++ -Wno-maybe-uninitialized -O2 -c -Wall -Wextra -Werror  -DNDEBUG -D_REENTRANT -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fPIC   -o _o/ChmIn.o  ../../Archive/Chm/ChmIn.cpp

Next error:

make -f makefile.gcc
g++ -Wno-maybe-uninitialized -O2 -c -Wall -Wextra -Werror  -DNDEBUG -D_REENTRANT -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fPIC   -o _o/UdfIn.o  ../../Archive/Udf/UdfIn.cpp

make -f makefile.gcc

success (not positive that this is done correctly with the flags I used), so binary test as described in the github project.

$ ./_o/bin/7zz i

7-Zip (z) 22.00 ZS v1.5.2 (x64) : Copyright (c) 1999-2022 Igor Pavlov : 2022-06-15
 64-bit locale=en_CA.UTF-8 Threads:12


Formats:
   C...F..........c.a.m+..  7z       7z            7 z BC AF ' 1C
    ......................  APFS     apfs img      offset=32 N X S B 00
    ......................  APM      apm           E R
    ......................  Ar       ar a deb udeb lib ! < a r c h > 0A
    ......................  Arj      arj           ` EA
    K.....O.....X.........  Base64   b64
    ......O...............  COFF     obj
    ...F..................  Cab      cab           M S C F 00 00 00 00
    ......................  Chm      chm chi chq chw I T S F 03 00 00 00 ` 00 00 00     ......................  Compound msi msp doc xls ppt D0 CF 11 E0 A1 B1 1A E1     ....M.................  Cpio     cpio          0 7 0 7 0  ||  C7 q  ||  q C7     ......................  CramFS   cramfs        offset=16 C o m p r e s s e d 20 R O M F S     .....G..B.............  Dmg      dmg           k o l y 00 00 00 04 00 00 02 00
    .........E............  ELF      elf            E L F
    ......................  Ext      ext ext2 ext3 ext4 img offset=1080 S EF
    ......................  FAT      fat img       offset=510 U AA
    ......................  FLV      flv           F L V 01
    ......................  GPT      gpt mbr       offset=512 E F I 20 P A R T 00 00 01 00     ....M.................  HFS      hfs hfsx      offset=1024 B D ||  H + 00 04  ||  H X 00 05     ...F..................  Hxs      hxs hxi hxr hxq hxw lit I T O L I T L S 01 00 00 00 ( 00 00 00
    ......O...............  IHex     ihex
    ......................  Iso      iso img       offset=32769 C D 0 0 1
    ......................  LP       lpimg img     offset=4096 g D l a 4 00 00 00
    ......................  Lzh      lzh lha       offset=2 - l h
    .......P..............  MBR      mbr
    ....M....E............  MachO    macho         CE FA ED FE  || CF FA ED FE  ||  FE ED FA CE  ||  FE ED FA CF
    ......................  MsLZ     mslz          S Z D D 88 F0 ' 3 A
    ....M.................  Mub      mub           CA FE BA BE 00 00 00  ||  B9 FA F1 0E     ......................  NTFS     ntfs img      offset=3 N T F S 20 20 20 20 00     ...F.G................  Nsis     nsis          offset=4 EF BE AD DE N u l l s o f t I n s t
    .........E............  PE       exe dll sys   M Z
    ......................  Ppmd     pmd           8F AF AC 84
    ......................  QCOW     qcow qcow2 qcow2c Q F I FB 00 00 00
    ...F..................  Rar      rar r00       R a r ! 1A 07 00
    ...F..................  Rar5     rar r00       R a r ! 1A 07 01 00
    ......................  Rpm      rpm           ED AB EE DB
    K.....................  SWF      swf           F W S
    ....M.................  SWFc     swf (~.swf)   C W S  ||  Z W S
    ......................  Sparse   simg img      : FF & ED 01 00
    ......................  Split    001
    ....M.................  SquashFS squashfs      h s q s  ||  s q s h  ||  s h s q  ||  q s h s
    .........E............  TE       te            V Z
    ...FM.................  UEFIc    scap          BD 86 f ; v 0D 0 @ B7 0E B5 Q 9E / C5 A0  ||  8B A6 < J # w FB H 80 = W 8C C1 FE C4 M  ||  B9 82 91 S B5 AB 91 C B6 9A E3 A9 C F7 / CC     ...FM.................  UEFIf    uefif         offset=16 D9 T 93 z h 04 J D 81 CE 0B F6 17 D8 90 DF  ||  x E5 8C 8C = 8A 1C O 99 5 89 a 85 C3 - D3     ......O...............  Udf      udf iso img   offset=32768 01 C D 0 0 1
    ......................  VDI      vdi           offset=64  10 DA BE
    .....G................  VHD      vhd           c o n e c t i x 00 00
    ......................  VHDX     vhdx avhdx    v h d x f i l e
    ......................  VMDK     vmdk          K D M V
    ......................  Xar      xar pkg xip   x a r ! 00 1C
    ......................  Z        z taz (.tar)  1F 9D
   CK.....................  bzip2    bz2 bzip2 tbz2 (.tar) tbz (.tar) B Z h
   CK.................m+..  gzip     gz gzip tgz (.tar) tpz (.tar) apk (.tar) 1F 8B 08
   CK.....................  lizard   liz tliz (.tar) 0 x 1 8 4 D 2 2 0 6 00
   CK.....................  lz4      lz4 tlz4 (.tar) 0 x 1 8 4 D 2 2 0 4 00
   CK.....................  lz5      lz5 tlz5 (.tar) 0 x 1 8 4 D 2 2 0 5 00
    K.....O...............  lzma     lzma
    K.....................  lzma86   lzma86
   C......O...LH......m+..  tar      tar ova       offset=257 u s t a r
   C.SN.......LH..c.a.m+..  wim      wim swm esd ppkg M S W I M 00 00 00
   CK.....................  xz       xz txz (.tar) FD 7 z X Z 00
   C...FMG........c.a.m+..  zip      zip z01 zipx jar xpi odt ods docx xlsx epub ipa apk appx P K 03 04  ||  P K 05 06  ||  P K 06 06 ||  P K 07 08 P K  ||  P K 0 0 P K    CK.....................  zstd     zst tzstd (.tar) 0 x F D 2 F B 5 2 2 . . 2 8 00    CK.....O.....XC........  Hash     sha256 sha512 sha224 sha384 sha1 sha md5 crc32 crc64 asc cksum

Codecs:
   4ED   303011B BCJ2
    EDF  3030103 BCJ
    EDF  3030205 PPC
    EDF  3030401 IA64
    EDF  3030501 ARM
    EDF  3030701 ARMT
    EDF  3030805 SPARC
    EDF    20302 Swap2
    EDF    20304 Swap4
    ED     40202 BZip2
    ED         0 Copy
    ED     40109 Deflate64
    ED     40108 Deflate
    EDF        3 Delta
    ED        21 LZMA2
    ED     30101 LZMA
    ED     30401 PPMD
    ED   4F71101 ZSTD
    ED   4F71104 LZ4
    ED   4F71102 BROTLI
    ED   4F71106 LIZARD
    ED   4F71105 LZ5
    ED        21 FLZMA2
    ED   4F71001 LZHAM
     D     40301 Rar1
     D     40302 Rar2
     D     40303 Rar3
     D     40305 Rar5
    EDF  6F10701 7zAES
    EDF  6F00181 AES256CBC

Hashers:
      4        1 CRC32
     20      201 SHA1
     32        A SHA256
      8        4 CRC64
     32      202 BLAKE2sp
     16      205 MD2
     16      206 MD4
     16      207 MD5
     48      208 SHA384
     64      209 SHA512
      4      203 XXH32
      8      204 XXH64
     32      20A BLAKE3

Which looks like the expected output, so I ran the test.

git clone https://github.com/jinfeihan57/p7zip_test_utils.git
cd p7zip_test_utils/check
bash check.sh  /path-to-p7zip/CPP/7zip/Bundles/Alone2/_o/bin/7zz

After a lot of output filled with messages of varying length like this:

7-Zip (z) 22.00 ZS v1.5.2 (x64) : Copyright (c) 1999-2022 Igor Pavlov : 2022-06-15
 64-bit locale=en_CA.UTF-8 Threads:12

Scanning the drive:
1 file, 462336 bytes (452 KiB)

Creating archive: 7za.exe.xz

Add new data to archive: 1 file, 462336 bytes (452 KiB)


Files read from disk: 1
Archive size: 194516 bytes (190 KiB)
Everything is Ok


I got this final result:

===========
ALL SUCCESS
===========

So I guess it compiled properly.

I did this on Fedora 42, so YMMV


On 2026-01-28 14:22, Nash JC - NCF via linux wrote:
Related to encryption, I've been investigating 7z. Struck me it might be sensible to have
the source code, but when I tried compiling following the instructions on
https://github.com/p7zip-project/p7zip
I immediately got a "file not found" error. I suspect that the downloadable executable
files were compiled slightly differently.

Anyone have ideas?

JN

To unsubscribe send a blank message to linux+unsubscribe [ at ] linux-ottawa [ dot ] org
To get help send a blank message to linux+help [ at ] linux-ottawa [ dot ] org
To visit the archives: https://lists.linux-ottawa.org


--
Scott Murphy



To unsubscribe send a blank message to linux+unsubscribe [ at ] linux-ottawa [ dot ] org
To get help send a blank message to linux+help [ at ] linux-ottawa [ dot ] org
To visit the archives: https://lists.linux-ottawa.org

message navigation