Menu

7-Zip (built reduced version from LZMA SDK ) cannot open .7z-archives

Help
Anton-V-K
2022-12-07
2022-12-07
  • Anton-V-K

    Anton-V-K - 2022-12-07

    I've managed to build the reduced version of 7-Zip console application from LZMA SDK 22.01 with VS2022 (the project files were created from scratch with only required sources).
    The Extract function (in \CPP\7zip\UI\Console\Main.cpp) ends with S_OK, however the content of simple .7z-archive isn't extracted, and it is counted as not-processed in the statistics:

    ...\7ZipReduced\Debug.Win32>7ZipReduced.exe x 7zip-Normal.7z
    
    7-Zip (a) 22.01 (x86) : Copyright (c) 1999-2022 Igor Pavlov : 2022-07-15
    
    Scanning the drive for archives:
    1 file, 23565 bytes (24 KiB)
    
    Extracting archive: 7zip-Normal.7z
    ERROR: 7zip-Normal.7z
    Cannot open the file as archive
    
    
    Can't open as archive: 1
    Files: 0
    Size:       0
    Compressed: 0
    

    The sample archive was created with ordinary version of 7-Zip (via FAR plugin) with Normal compression level (attached for references).
    The archive can be extracted fine with the pre-built console app 7zr.exe:

    ...\lzma2201\bin>7zr.exe x 7zip-Normal.7z
    
    7-Zip (r) 22.01 (x86) : Igor Pavlov : Public domain : 2022-07-15
    
    Scanning the drive for archives:
    1 file, 23565 bytes (24 KiB)
    
    Extracting archive: 7zip-Normal.7z
    --
    Path = 7zip-Normal.7z
    Type = 7z
    Physical Size = 23565
    Headers Size = 698
    Method = LZMA:17
    Solid = +
    Blocks = 1
    
    Everything is Ok
    
    Folders: 8
    Files: 21
    Size:       127048
    Compressed: 23565
    

    Since no source files were modified by me, I tend to think that something is wrong with my project's settings.
    Can someone give me a hint where to look for the problem's cause?
    Thanks in advance!

     

    Last edit: Anton-V-K 2022-12-07
  • Anton-V-K

    Anton-V-K - 2022-12-07

    Here is the archive with projects and sources I use for building the static library and the application.

     
  • Igor Pavlov

    Igor Pavlov - 2022-12-07

    7-zip uses static plugins that can be registerd with
    *Register.cpp and *Reg.cpp files and some another files.
    So you must include all such files.
    look the list of all files:

    CPP\7zip\Bundles\Alone7z\makefile
    
    7Z_OBJS = \
      $O\7zCompressionMode.obj \
      $O\7zDecode.obj \
      $O\7zEncode.obj \
      $O\7zExtract.obj \
      $O\7zFolderInStream.obj \
      $O\7zHandler.obj \
      $O\7zHandlerOut.obj \
      $O\7zHeader.obj \
      $O\7zIn.obj \
      $O\7zOut.obj \
      $O\7zProperties.obj \
      $O\7zRegister.obj \
      $O\7zSpecStream.obj \
      $O\7zUpdate.obj \
    
    COMPRESS_OBJS = \
      $O\Bcj2Coder.obj \
      $O\Bcj2Register.obj \
      $O\BcjCoder.obj \
      $O\BcjRegister.obj \
      $O\BranchMisc.obj \
      $O\BranchRegister.obj \
      $O\ByteSwap.obj \
      $O\CopyCoder.obj \
      $O\CopyRegister.obj \
      $O\DeltaFilter.obj \
      $O\Lzma2Decoder.obj \
      $O\Lzma2Encoder.obj \
      $O\Lzma2Register.obj \
      $O\LzmaDecoder.obj \
      $O\LzmaEncoder.obj \
      $O\LzmaRegister.obj \
      $O\XzDecoder.obj \
      $O\XzEncoder.obj \
    
    CRYPTO_OBJS = \
      $O\7zAes.obj \
      $O\7zAesRegister.obj \
      $O\MyAes.obj \
      $O\MyAesReg.obj \
      $O\RandGen.obj \
    
     
    👍
    1
  • Anton-V-K

    Anton-V-K - 2022-12-07

    Igor, thanks a lot for the reply. It helped me a lot!
    I've managed to restructure the sources, so the 7z console app can now be built in a working state. I've attached the project for references.
    Extra note: it is hardly possible to put all LZMA SDK sources in a static library, since the plugins registrations are usually optimized by the linker, so they are stripped from the resulting executable. And you have to either build the library as dynamic, or compile some sources as a part of your application.

     

Log in to post a comment.