Re: How to install Compress::Stream::Zstd in Strawberry Perl?
by swl (Prior) on Mar 05, 2025 at 01:14 UTC
|
It's probably worth looking at Alien::zstd.
Add its bin_dir to your path before building Compress::Stream::Zstd and see how things work. You might also need to add the pkgconf dir to the PKG_CONFIG_PATH env var (although it seems not to use pkg-config).
Edit: Nope. That hits the same issues. Looks like more tweaking is needed, possibly to the C::S::Z build process.
| [reply] [d/l] [select] |
|
Huh, first post in three years.
I tried this with Alien::zstd and it seems to work out and the .a file is deep under site/:
cpan Alien::zstd
I let that run for awhile, because I have an underpowered Surface 8.
C:\strawberry\perl\site\lib\auto\share\dist\Alien-zstd\lib\libzstd.a
I don't know about the path to point to this (please add those steps if you know the proper way), so I did the simple and expedient thing of going into the cpan/build/Compress-Stream-Zlib-0.206-0 directory (the last digits may be different for you). Under ext/zstd/lib is the source for Zstd, but I'm not falling that again. Instead of building all that, I simply copied the previous libzstd.a file into it:
cp C:\strawberry\perl\site\lib\auto\share\dist\Alien-zstd\lib\libzstd.
+a .\ext\zstd\lib
Then I ran the Build steps and it seems to work out:
perl ./Build.PL
./Build
./Build test
./Build install
Now the trick is packaging that for a distributed single-file app.
--
brian d foy <brian.d.foy@gmail.com>
| [reply] [d/l] [select] |
|
I hacked into the builder\MyBuilder.pm file to get the same build result but with more effort.
That said I get test failures, although these look like problems with the tests given the expected version is hard-coded to 1.5.5.
t\01_basic.t ................ #
# Compress::Stream::Zstd Version 0.206
# ZSTD_VERSION_NUMBER 10507
# ZSTD_VERSION_STRING 1.5.7
# ZSTD_MAX_CLEVEL 22
# ZSTD_MIN_CLEVEL -131072
#
t\01_basic.t ................ 1/?
t\01_basic.t ................ 1/?
# Failed test at t\01_basic.t line 30.
# got: '10507'
# expected: '10505'
# Failed test at t\01_basic.t line 31.
# got: '1.5.7'
# expected: '1.5.5'
# Looks like you failed 2 tests of 16.
t\01_basic.t ................ Dubious, test returned 2 (wstat 512, 0x2
+00)
| [reply] [d/l] [select] |
Re: How to install Compress::Stream::Zstd in Strawberry Perl?
by choroba (Cardinal) on Mar 04, 2025 at 22:37 UTC
|
The testers' results aren't very promising.
map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
| [reply] [d/l] |
|
Yes, that's disappointing. Thanks for pointing it out.
I've been googling all day and not getting much help there.
There exists an active GitHub site with a zstd-v1.5.7-win64.zip downloadable file, as well as the source code.
I just can't figure out how to set that up so Strawberry Perl's CPAN can hook into it.
Any thoughts greatly appreciated!
| [reply] |
|
There exists an active GitHub site with a zstd-v1.5.7-win64.zip downloadable file
Yep - that should do the trick.
Copy its dll/libzstd.dll.a into the ext/zstd/lib folder, and rename it to libzstd.a.
Then copy the dll/libzstd.dll file into your strawberry/perl/bin folder.
Then just do step "5." from my earlier post.
Worked for me !!
Cheers, Rob
| [reply] |
Re: How to install Compress::Stream::Zstd in Strawberry Perl?
by syphilis (Archbishop) on Mar 05, 2025 at 00:15 UTC
|
I'm asking for help installing Compress::Stream::Zstd in Strawberry Perl on a windows 10 box.
Here is a process that worked for me on Windows 11 with StrawberryPerl-5.40.1.
But it relies on MSYS2 being installed.
1. Download and unpack the Compress-Stream-Zstd source from https://cpan.metacpan.org/authors/id/P/PM/PMQS/Compress-Stream-Zstd-0.206.tar.gz
2. In the MSYS2 shell, cd to the Compress-Stream-Zstd-0.206/ext/zstd folder.
3. In the MSYS2 shell, insert Strawberry Perl compiler at the end of the PATH (as my MSYS2 installation doesn't include a compiler package). For me, that was:
$ export PATH=$PATH:/c/sp/_64/sp-5.40.0.1-PDL/c/bin
4. In the MSYS2 shell, run "make CC=gcc":
$ make CC=gcc
5. When that has finished, open a Windows cmd.exe shell that is set up to run Strawberry Perl, and cd to the Compress-Stream-Zstd-0.206 folder into which the tar.gz file was unpacked and run, in order:
> perl Build.PL
> perl Build
> perl Build test
> perl Build install.
Here is the output I got from running the test suite:
<c>
D:\s\Compress-Stream-Zstd-0.206>perl Build test
t\00_compile.t .............. ok
t\01_basic.t ................ #
# Compress::Stream::Zstd Version 0.206
# ZSTD_VERSION_NUMBER 10505
# ZSTD_VERSION_STRING 1.5.5
# ZSTD_MAX_CLEVEL 22
# ZSTD_MIN_CLEVEL -131072
#
t\01_basic.t ................ ok
t\02_streaming.t ............ ok
t\03_context.t .............. ok
t\04_dictionary.t ........... ok
t\05_streaming_windowlog.t .. ok
All tests successful.
Files=6, Tests=45, 1 wallclock secs ( 0.08 usr + 0.01 sys = 0.09 CP
+U)
Result: PASS
There might be other ways to achieve success. (Maybe use Cygwin instead of MSYS2 ?)
Perhaps, simply plonking a satisfactory libzstd.a in the ext/zstd/lib folder is all that's needed for step "5." to work.
If your MSYS2 installation has a compiler package, then you won't need step "3.".
UPDATE:
In fact, just plonking a suitable libzstd.a into the ext/zstd/lib folder is apparently all that's needed.
With that done, it's simply a matter of executing step "5."
Post (or /msg) me an email address, and I'll send the libzstd.a file (1.07 MB) over, and you can try for yourself.
Cheers, Rob
| [reply] [d/l] [select] |
SOLUTION: How to install Compress::Stream::Zstd in Strawberry Perl?
by cmv (Chaplain) on Mar 08, 2025 at 03:07 UTC
|
Monks-
This place is fantastic, as are the people who contribute! No wonder Perl continues to be my preferred language.
I just wanted to describe the final solution that I ended up using, for anyone else who need this help.
Shout outs for:
Ok, here is what worked for me on a Windows 10 box:
- Install Strawberry Perl following the label directions
- Startup CPAN shell & install Alien::Zstd
$ perl -MCPAN -e shell
cpan> install Alien::Zstd
- Once successfully completed, verify the location of the libzstd.a library that was just built
c:/Strawberry/perl/site/lib/auto/share/dist/Alien-zstd/lib/libzstd.a
- Back in CPAN shell, try to install Compress::Stream::Zstd (it should fail)
cpan> install Compress::Stream::Zstd
...
The system cannot find the file specified
-or-
Cannot find ext/zstd/lib/libzstd.a: No such file or directory
-or-
Something similar
- Figure out where CPAN is building your Compress::Stream::Zstd
c:/Strawberry/cpan/build/Compress-Stream-Zstd-0.206-0
-
Copy the Alien::zstd libzstd.a file to where Compress::Stream::Zstd expects it to be:
$ copy c:/Strawberry/perl/site/lib/auto/share/dist/Alien-zstd/lib/libz
+std.a c:/Strawberry/cpan/build/Compress-Stream-Zstd-0.206-0/ext/zstd/
+lib
- Go to the CPAN build directory for Compress::Stream::Zstd and finish building by hand:
$ cd c:/Strawberry/cpan/build/Compress-Stream-Zstd-0.206-0
$ perl ./Build.PL
$ ./Build
$ ./Build test
$ ./Build install
- That should complete successfully, and you are now done!
| [reply] [d/l] [select] |
|
Good to see it works, and thanks for the set of steps.
In the interests of TIMTOWTDI, steps 4-7 could be simplified using cpanm. Calling cpanm --look opens a shell in the build directory. On Windows it is a cmd chell.
(Untested)
cpanm --look Compress::Stream::Zstd
:: You are now in the build dir
:: This next line prints the location of the Alien::Zstd files, under
+which will be libzstd.a
perl -MAlien::Zstd -E"say Alien::Zstd->dist_dir"
:: assuming it is in the dir you noted in your post the line would be
copy c:/Strawberry/perl/site/lib/auto/share/dist/Alien-zstd/lib/libzst
+d.a ext\zstd\lib
:: (One could also use File::Copy to use perl to find and copy the fil
+e in one step)
:: build, test, install
perl .\Build.PL && build && build test && build install
:: back to your previous shell
exit
| [reply] [d/l] [select] |
Re: How to install Compress::Stream::Zstd in Strawberry Perl?
by cavac (Prior) on Mar 05, 2025 at 14:47 UTC
|
Hmm, on Linux (Ubuntu 24.04 LTS 64bit) it seems to build the lib in place without problems:
$ cpan install Compress::Stream::Zstd
Reading '/home/cavac/.cpan/Metadata'
Database was generated on Tue, 04 Mar 2025 06:29:02 GMT
CPAN: HTTP::Tiny loaded ok (v0.090)
CPAN: Net::SSLeay loaded ok (v1.94)
CPAN: IO::Socket::SSL loaded ok (v2.089)
Fetching with HTTP::Tiny:
https://cpan.org/authors/01mailrc.txt.gz
Reading '/home/cavac/.cpan/sources/authors/01mailrc.txt.gz'
CPAN: Compress::Zlib loaded ok (v2.213)
......................................................................
+......DONE
Fetching with HTTP::Tiny:
https://cpan.org/modules/02packages.details.txt.gz
Reading '/home/cavac/.cpan/sources/modules/02packages.details.txt.gz'
Database was generated on Wed, 05 Mar 2025 14:17:02 GMT
CPAN: HTTP::Date loaded ok (v6.06)
......................................................................
+......DONE
Fetching with HTTP::Tiny:
https://cpan.org/modules/03modlist.data.gz
Reading '/home/cavac/.cpan/sources/modules/03modlist.data.gz'
DONE
Writing /home/cavac/.cpan/Metadata
Running install for module 'Compress::Stream::Zstd'
Fetching with HTTP::Tiny:
https://cpan.org/authors/id/P/PM/PMQS/Compress-Stream-Zstd-0.206.tar.g
+z
CPAN: Digest::SHA loaded ok (v6.04)
Checksum for /home/cavac/.cpan/sources/authors/id/P/PM/PMQS/Compress-S
+tream-Zstd-0.206.tar.gz ok
CPAN: YAML loaded ok (v1.31)
CPAN: CPAN::Meta::Requirements loaded ok (v2.143)
CPAN: Parse::CPAN::Meta loaded ok (v2.150010)
CPAN: CPAN::Meta loaded ok (v2.150010)
CPAN: Module::CoreList loaded ok (v5.20250120)
Configuring P/PM/PMQS/Compress-Stream-Zstd-0.206.tar.gz with Build.PL
Created MYMETA.yml and MYMETA.json
Creating new 'Build' script for 'Compress-Stream-Zstd' version '0.206'
PMQS/Compress-Stream-Zstd-0.206.tar.gz
/home/cavac/bin/CavacPerl-5.40.1/bin/perl Build.PL -- OK
Running Build for P/PM/PMQS/Compress-Stream-Zstd-0.206.tar.gz
make: Entering directory '/home/cavac/.cpan/build/Compress-Stream-Zstd
+-0.206-0/ext/zstd/lib'
CC obj/conf_5413757261b9f41abdf3d55d0a87b321/static/debug.o
CC obj/conf_5413757261b9f41abdf3d55d0a87b321/static/entropy_common.o
CC obj/conf_5413757261b9f41abdf3d55d0a87b321/static/error_private.o
CC obj/conf_5413757261b9f41abdf3d55d0a87b321/static/fse_decompress.o
CC obj/conf_5413757261b9f41abdf3d55d0a87b321/static/pool.o
CC obj/conf_5413757261b9f41abdf3d55d0a87b321/static/threading.o
CC obj/conf_5413757261b9f41abdf3d55d0a87b321/static/xxhash.o
CC obj/conf_5413757261b9f41abdf3d55d0a87b321/static/zstd_common.o
CC obj/conf_5413757261b9f41abdf3d55d0a87b321/static/zstd_v05.o
CC obj/conf_5413757261b9f41abdf3d55d0a87b321/static/zstd_v06.o
CC obj/conf_5413757261b9f41abdf3d55d0a87b321/static/zstd_v07.o
CC obj/conf_5413757261b9f41abdf3d55d0a87b321/static/fse_compress.o
CC obj/conf_5413757261b9f41abdf3d55d0a87b321/static/hist.o
CC obj/conf_5413757261b9f41abdf3d55d0a87b321/static/huf_compress.o
CC obj/conf_5413757261b9f41abdf3d55d0a87b321/static/zstd_compress.o
CC obj/conf_5413757261b9f41abdf3d55d0a87b321/static/zstd_compress_lite
+rals.o
CC obj/conf_5413757261b9f41abdf3d55d0a87b321/static/zstd_compress_sequ
+ences.o
CC obj/conf_5413757261b9f41abdf3d55d0a87b321/static/zstd_compress_supe
+rblock.o
CC obj/conf_5413757261b9f41abdf3d55d0a87b321/static/zstd_double_fast.o
CC obj/conf_5413757261b9f41abdf3d55d0a87b321/static/zstd_fast.o
CC obj/conf_5413757261b9f41abdf3d55d0a87b321/static/zstd_lazy.o
CC obj/conf_5413757261b9f41abdf3d55d0a87b321/static/zstd_ldm.o
CC obj/conf_5413757261b9f41abdf3d55d0a87b321/static/zstd_opt.o
CC obj/conf_5413757261b9f41abdf3d55d0a87b321/static/zstdmt_compress.o
CC obj/conf_5413757261b9f41abdf3d55d0a87b321/static/huf_decompress.o
CC obj/conf_5413757261b9f41abdf3d55d0a87b321/static/zstd_ddict.o
CC obj/conf_5413757261b9f41abdf3d55d0a87b321/static/zstd_decompress.o
CC obj/conf_5413757261b9f41abdf3d55d0a87b321/static/zstd_decompress_bl
+ock.o
AS obj/conf_5413757261b9f41abdf3d55d0a87b321/static/huf_decompress_amd
+64.o
CC obj/conf_5413757261b9f41abdf3d55d0a87b321/static/cover.o
CC obj/conf_5413757261b9f41abdf3d55d0a87b321/static/divsufsort.o
CC obj/conf_5413757261b9f41abdf3d55d0a87b321/static/fastcover.o
CC obj/conf_5413757261b9f41abdf3d55d0a87b321/static/zdict.o
compiling single-threaded static library 1.5.5
make: Leaving directory '/home/cavac/.cpan/build/Compress-Stream-Zstd-
+0.206-0/ext/zstd/lib'
Building Compress-Stream-Zstd
cc -I/home/cavac/bin/CavacPerl-5.40.1/lib/perl5/5.40.1/x86_64-linux/CO
+RE '-DVERSION="0.206"' '-DXS_VERSION="0.206"' -fPIC -Wall -Wextra -Wn
+o-parentheses -Wno-unused -Wno-unused-parameter -I. -Iext/zstd/lib -D
+ZSTD_LEGACY_MULTITHREADED_API -c -fwrapv -fno-strict-aliasing -pipe -
+fstack-protector-strong -I/usr/local/include -D_LARGEFILE_SOURCE '-D_
+FILE_OFFSET_BITS=64' -O2 -o lib/Compress/Stream/Zstd.o lib/Compress/S
+tream/Zstd.c
ExtUtils::Mkbootstrap::Mkbootstrap('blib/arch/auto/Compress/Stream/Zst
+d/Zstd.bs')
cc -shared -O2 -L/usr/local/lib -fstack-protector-strong -o blib/arch/
+auto/Compress/Stream/Zstd/Zstd.so lib/Compress/Stream/Zstd.o -pthread
+ ext/zstd/lib/libzstd.a
PMQS/Compress-Stream-Zstd-0.206.tar.gz
./Build -- OK
CPAN: CPAN::DistnameInfo loaded ok (v0.12)
Running Build test for PMQS/Compress-Stream-Zstd-0.206.tar.gz
t/00_compile.t .............. ok
t/01_basic.t ................ #
# Compress::Stream::Zstd Version 0.206
# ZSTD_VERSION_NUMBER 10505
# ZSTD_VERSION_STRING 1.5.5
# ZSTD_MAX_CLEVEL 22
# ZSTD_MIN_CLEVEL -131072
#
t/01_basic.t ................ ok
t/02_streaming.t ............ ok
t/03_context.t .............. ok
t/04_dictionary.t ........... ok
t/05_streaming_windowlog.t .. ok
All tests successful.
Files=6, Tests=45, 0 wallclock secs ( 0.01 usr 0.01 sys + 0.16 cusr
+ 0.03 csys = 0.21 CPU)
Result: PASS
PMQS/Compress-Stream-Zstd-0.206.tar.gz
./Build test -- OK
Running Build install for PMQS/Compress-Stream-Zstd-0.206.tar.gz
Building Compress-Stream-Zstd
Files found in blib/arch: installing files in blib/lib into architectu
+re dependent library tree
Installing /home/cavac/bin/CavacPerl-5.40.1/lib/perl5/site_perl/5.40.1
+/x86_64-linux/auto/Compress/Stream/Zstd/Zstd.so
Installing /home/cavac/bin/CavacPerl-5.40.1/lib/perl5/site_perl/5.40.1
+/x86_64-linux/auto/Compress/Stream/Zstd/Zstd.bs
Installing /home/cavac/bin/CavacPerl-5.40.1/lib/perl5/site_perl/5.40.1
+/x86_64-linux/Compress/Stream/Zstd.pm
Installing /home/cavac/bin/CavacPerl-5.40.1/lib/perl5/site_perl/5.40.1
+/x86_64-linux/Compress/Stream/Zstd/CompressionDictionary.pm
Installing /home/cavac/bin/CavacPerl-5.40.1/lib/perl5/site_perl/5.40.1
+/x86_64-linux/Compress/Stream/Zstd/DecompressionDictionary.pm
Installing /home/cavac/bin/CavacPerl-5.40.1/lib/perl5/site_perl/5.40.1
+/x86_64-linux/Compress/Stream/Zstd/Compressor.pm
Installing /home/cavac/bin/CavacPerl-5.40.1/lib/perl5/site_perl/5.40.1
+/x86_64-linux/Compress/Stream/Zstd/CompressionContext.pm
Installing /home/cavac/bin/CavacPerl-5.40.1/lib/perl5/site_perl/5.40.1
+/x86_64-linux/Compress/Stream/Zstd/Decompressor.pm
Installing /home/cavac/bin/CavacPerl-5.40.1/lib/perl5/site_perl/5.40.1
+/x86_64-linux/Compress/Stream/Zstd/DecompressionContext.pm
Installing /home/cavac/bin/CavacPerl-5.40.1/man/man3/Compress::Stream:
+:Zstd::CompressionContext.3
Installing /home/cavac/bin/CavacPerl-5.40.1/man/man3/Compress::Stream:
+:Zstd.3
Installing /home/cavac/bin/CavacPerl-5.40.1/man/man3/Compress::Stream:
+:Zstd::DecompressionDictionary.3
Installing /home/cavac/bin/CavacPerl-5.40.1/man/man3/Compress::Stream:
+:Zstd::CompressionDictionary.3
Installing /home/cavac/bin/CavacPerl-5.40.1/man/man3/Compress::Stream:
+:Zstd::Decompressor.3
Installing /home/cavac/bin/CavacPerl-5.40.1/man/man3/Compress::Stream:
+:Zstd::Compressor.3
Installing /home/cavac/bin/CavacPerl-5.40.1/man/man3/Compress::Stream:
+:Zstd::DecompressionContext.3
PMQS/Compress-Stream-Zstd-0.206.tar.gz
./Build install -- OK
But i have no idea if the lib itself is up-to-date. I somehow have my doubts, since the last change mentions . There were quite a few security problems with zstd in recent years. The CPAN module mentions "updated to the version from April 2023", but there seem to be quite a few CVEs after that that mention zstd: https://cve.mitre.org/cgi-bin/cvekey.cgi?keyword=zstd. The libs Github release page also shows a lot of fixed bugs: https://github.com/facebook/zstd/releases.
That is, if my google-foo didn't mess up. I'm not really that familiar with this compression library, i have yet to motivate myself to go through the process of adding yet another set of "standard" compression algos to my webserver framework and evaluate the memory/speed/caching tradeoffs.
| [reply] [d/l] |
Re: How to install Compress::Stream::Zstd in Strawberry Perl?
by etj (Priest) on Mar 08, 2025 at 15:24 UTC
|
| [reply] |
Re: How to install Compress::Stream::Zstd in Strawberry Perl?
by Anonymous Monk on Mar 04, 2025 at 20:45 UTC
|
FWIW, the last time I tried (2022 it was, c/p-ing now from a script), I gave up, and, to decompress:
my $in = ...;
my $out;
my @cmd = qw/zstd.exe -d -/;
IPC::Run3::run3 \@cmd, \$in, \$out, \undef, { binmode_stdin => ':raw',
+ binmode_stdout => ':raw' };
HTH ;) | [reply] [d/l] |
|
Yes, this will be my backup plan.
However, I was able to get the module successfully installed and working on my development machine (Mac-Mini). Hmmm...
A search for the missing windows 10 library reveals the following on the Mac (with checksums):
54918 702 ~/.cpan/build/Compress-Zstd-0.20-0/ext/zstd/lib/libzstd.a
14207 788 ~/.cpan/build/Compress-Stream-Zstd-0.206-0/ext/zstd/lib/obj/
+conf_bd2d977386eb0c0c4c6c1128107e0a49/static/libzstd.a
14207 788 ~/.cpan/build/Compress-Stream-Zstd-0.206-0/ext/zstd/lib/libz
+std.a
47868 821 /opt/homebrew/Cellar/zstd/1.5.2/lib/libzstd.a
Clearly I first used homebrew to download the zstd command, but I don't know if CPAN was smart enough to find libzstd.a there and use that one. Since the checksums are different I'm guessing that CPAN built its own libzstd.a.
So then why didn't windows build its own libzstd.a as well?? | [reply] [d/l] |