0xfeedbacc
0xfeedbacc

Reputation: 321

Libarchive: how to compress an archive on windows?

I am trying to create a compressed archive on windows with libarchive and at the moment it is not working. I can create zip or pax_restricted(tar) archives without compression, without any problems.

To add compression I've tried some combinations of the following:

archive_write_set_compression_lzip(lWriteArchive);
archive_write_add_filter_lzip(lWriteArchive);

archive_write_set_compression_gzip(lWriteArchive);
archive_write_add_filter_gzip(lWriteArchive);

archive_write_set_format_zip(lWriteArchive);
archive_write_set_format_pax_restricted(lWriteArchive);

I've mainly tried using lzip compression with the zip format and gzip compression with the pax_restricted format.

First I'm not sure whether I should use archive_write_set_compression_* or archive_write_add_filter_*.

When I try add lzip compression and I step into the function I see it returns ARCHIVE_FATAL with the error message "lzma compression not supported on this platform".

When I try to add gzip compression and I step into the function I see it returns ARCHIVE_WARN with the error message "Using external gzip program". If I let the process go on the resulting archive has a size of zero.

I get the feeling like on unix systems there are system libraries for lzma and gzip that libarchive uses for compression and that these are not available on windows.

I built libarchive using the latest stable release, following the the instructions to use CMake etc. I didn't notice any errors in the CMake configuration like I was missing lzma or gzip.

Thanks for any help.

Upvotes: 6

Views: 1133

Answers (1)

1xBadAdvice
1xBadAdvice

Reputation: 11

I got ARCHIVE_WARN with error message "Using external gzip program" on an Ubuntu 22.04.3 LTS machine from a C++ program attempting to invoke libarchive-3.7.2. Solved it by manually building and installing libarchive-3.7.2 from sources. (The machine is locked down, so apt is not available). I suppose the program builds but fails because it is unable to load the archive library at run time.

Upvotes: 0

Related Questions