StrawberryPerl / Perl-Dist-Strawberry

Tooling to build and package releases for Perl on Windows.
https://strawberryperl.com
Other
284 stars 48 forks source link

Graphics module not installing or acting weird #26

Open sumanstats opened 3 years ago

sumanstats commented 3 years ago

I am trying to use PDL(https://metacpan.org/pod/PDL) and for plotting the ndarrays, I need Graphics libraries. So I tried to install PDL::Graphics::PGPLOT

cpanm PDL::Graphics::PGPLOT
--> Working on PDL::Graphics::PGPLOT
Fetching http://www.cpan.org/authors/id/E/ET/ETJ/PDL-2.047.tar.gz ... OK
Configuring PDL-2.047 ... OK
Building and testing PDL-2.047 ... OK
Successfully installed PDL-2.047
1 distribution installed

and PDL::Graphics::PLplot

C:\strawberry-perl-5.32.1.1-64bit-PDL>cpanm PDL::Graphics::PLplot
--> Working on PDL::Graphics::PLplot
Fetching http://www.cpan.org/authors/id/D/DH/DHUNT/PDL-Graphics-PLplot-0.74.tar.gz ... OK
Configuring PDL-Graphics-PLplot-0.74 ... OK
Building and testing PDL-Graphics-PLplot-0.74 ... OK
Successfully installed PDL-Graphics-PLplot-0.74
1 distribution installed

Trying to use those libraries throw error:

pdl> use PDL::Grpahics::PGPLOT
Compile error: Can't locate PDL/Grpahics/PGPLOT.pm in @INC (you may need to install the PDL::Grpahics::PGPLOT module) (@INC contains: C:/strawberry-perl-5.32.1.1-64bit-PDL/perl/site/lib/MSWin32-x64-multi-thread C:/strawberry-perl-5.32.1.1-64bit-PDL/perl/site/lib C:/strawberry-perl-5.32.1.1-64bit-PDL/perl/vendor/lib C:/strawberry-perl-5.32.1.1-64bit-PDL/perl/lib) at (eval 414) line 7.
BEGIN failed--compilation aborted at (eval 414) line 7.
pdl> use PDL::Grpahics::PLplot
Compile error: Can't locate PDL/Grpahics/PLplot.pm in @INC (you may need to install the PDL::Grpahics::PLplot module) (@INC contains: C:/strawberry-perl-5.32.1.1-64bit-PDL/perl/site/lib/MSWin32-x64-multi-thread C:/strawberry-perl-5.32.1.1-64bit-PDL/perl/site/lib C:/strawberry-perl-5.32.1.1-64bit-PDL/perl/vendor/lib C:/strawberry-perl-5.32.1.1-64bit-PDL/perl/lib) at (eval 422) line 7.
BEGIN failed--compilation aborted at (eval 422) line 7.

To practice examples on http://pdl.perl.org/?page=FirstSteps I again tried installing PDL::Graphics::Simple

C:\strawberry-perl-5.32.1.1-64bit-PDL>cpanm PDL::Graphics::Simple
--> Working on PDL::Graphics::Simple
Fetching http://www.cpan.org/authors/id/Z/ZO/ZOWIE/PDL-Graphics-Simple-1.005.tar.gz ... OK
Configuring PDL-Graphics-Simple-1.005 ... OK
Building and testing PDL-Graphics-Simple-1.005 ... FAIL
! Installing PDL::Graphics::Simple failed. See C:\strawberry-perl-5.32.1.1-64bit-PDL\data\.cpanm\work\1621510604.10224\build.log for details. Retry with --force to force install it.

but it fails. Using --force however installs but using it in program fails:

pdl> use PDL::Graphics::Simple
pdl> imag (sin(rvals(200,200)+1))
Trying gnuplot (PDL::Graphics::Gnuplot)...PDL::Graphics::SImple: Gnuplot exists but yours doesn't support either the x11 or wxt terminal
Trying pgplot (PDL::Graphics::PGPLOT::Window)...nope
Trying plplot (PDL::Graphics::PLplot)...nope
Trying prima (PDL::Graphics::Prima)...nope
Runtime error: Sorry, all known plotting engines failed.  Install one and try again.
pdl>

Looking at the error Gnuplot exists but yours doesn't support either the x11 or wxt terminal, I don't know what to do.

How to get over this error and use PDL with strawberry perl? Any help?

sisyphus commented 3 years ago

Hi, As regards the pdl2 shell, I'd recommend just using it and see if it works ok for you. I seemed to fare a little better than you:

pdl2 Unable to get Terminal Size. The Win32 GetConsoleScreenBufferInfo call didn't work. The COLUMNS and LINES environment variables didn't work. at C:/_64/strawberry-5.32.1-PDL/perl/vendor/lib/Term/ReadLine/readline.pm line 410. load_rcfile: got $HOME = C:_64\strawberry-5.32.1-PDL\data load_rcfile: loading PDL/default.pdl Perldl2 Shell v0.008 PDL comes with ABSOLUTELY NO WARRANTY. For details, see the file 'COPYING' in the PDL distribution. This is free software and you are welcome to redistribute it under certain conditions, see the same file for details. Loaded plugins: CleanErrors Commands Completion CompletionDriver::INC CompletionDriver::Keywords CompletionDriver::LexEnv CompletionDriver::Methods DDS FindVariable History LexEnv MultiLine::PPI NiceSlice PDLCommands Packages PrintControl ReadLineHistory Type 'help' for online help Type Ctrl-D or quit to exit Loaded PDL v2.025

pdl>

You'll need the pgplot library in order to build PGPLOT and PDL::Graphics::PGPLOT. If you like, I can send you the pgplot library that I used when I was building those 2 perl modules.

Strawberry ships with the plplot library, so PDL::Graphics::PLplot-0.74 should be buildable. That module is currently broken for Windows - but the breakage is hopefully fixable.

Download https://cpan.metacpan.org/authors/id/D/DH/DHUNT/PDL-Graphics-PLplot-0.74.tar.gz, unpack it and cd to the top level directory ( PDL-Graphics-PLplot-0.74). Then run 'perl Makefile.PL'. I get the following braindead rubbish:

C:\sisyphusion\PDL-Graphics-PLplot-0.74>perl Makefile.PL PDL is installed

Checking PDL::Graphics::PLplot... Searching for libplplot.dll library. Searching for libplplotd.dll library. Cannot find plplot library (libplplotd.dll), skipping PDL::Graphics::PLplot

  Not building PDL::Graphics::PLplot

Cannot find plplot library (libplplotd.dll), skipping PDL::Graphics::PLplot Not building PDL::Graphics::PLplot Checking if your kit is complete... Looks good

So, the first thing to try is to fix the Makefile.PL so that libplplot.dll (which exists in c/bin) is located. At line 57 of the Makefile.PL, I inserted the location of libplplot.dll:

foreach my $libdir ( 'C:/_64/strawberry-5.32.1-PDL/c/bin', # location of libplplot.dll on my machine ...

I also set 2 environment variables:

set PLPLOT_LIBDIR=C:/_64/strawberry-5.32.1-PDL/c/lib set PLPLOT_INCDIR=C:/_64/strawberry-5.32.1-PDL/c/include/plplot

The 'perl Makefile.PL' step then succeeded. Next, I ran 'gmake test', but there was an undefined reference:

gmake test ... C:/_64/strawberry-5.32.1-PDL/c/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: PLplot.o:PLplot.c:(.text+0x91b59): undefined reference to `c_plshade1' collect2.exe: error: ld returned 1 exit status gmake: *** [Makefile:481: blib\arch\auto\PDL\Graphics\PLplot\PLplot.xs.dll] Error 1

I don't know why that is happening. It's late over here, and the rest will have to wait until tomorrow. Maybe you can make some more progress in the meantime.

Cheers, Rob

On Thu, May 20, 2021 at 10:49 PM Suman Khanal @.***> wrote:

I am trying to use PDL(https://metacpan.org/pod/PDL) and for plotting the ndarrays, I need Graphics libraries. So I tried to install PDL::Graphics::PGPLOT

cpanm PDL::Graphics::PGPLOT --> Working on PDL::Graphics::PGPLOT Fetching http://www.cpan.org/authors/id/E/ET/ETJ/PDL-2.047.tar.gz ... OK Configuring PDL-2.047 ... OK Building and testing PDL-2.047 ... OK Successfully installed PDL-2.047 1 distribution installed

and PDL::Graphics::PLplot

C:\strawberry-perl-5.32.1.1-64bit-PDL>cpanm PDL::Graphics::PLplot --> Working on PDL::Graphics::PLplot Fetching http://www.cpan.org/authors/id/D/DH/DHUNT/PDL-Graphics-PLplot-0.74.tar.gz ... OK Configuring PDL-Graphics-PLplot-0.74 ... OK Building and testing PDL-Graphics-PLplot-0.74 ... OK Successfully installed PDL-Graphics-PLplot-0.74 1 distribution installed

Trying to use those libraries throw error:

pdl> use PDL::Grpahics::PGPLOT Compile error: Can't locate PDL/Grpahics/PGPLOT.pm in @INC (you may need to install the PDL::Grpahics::PGPLOT module) (@INC contains: C:/strawberry-perl-5.32.1.1-64bit-PDL/perl/site/lib/MSWin32-x64-multi-thread C:/strawberry-perl-5.32.1.1-64bit-PDL/perl/site/lib C:/strawberry-perl-5.32.1.1-64bit-PDL/perl/vendor/lib C:/strawberry-perl-5.32.1.1-64bit-PDL/perl/lib) at (eval 414) line 7. BEGIN failed--compilation aborted at (eval 414) line 7.

pdl> use PDL::Grpahics::PLplot Compile error: Can't locate PDL/Grpahics/PLplot.pm in @INC (you may need to install the PDL::Grpahics::PLplot module) (@INC contains: C:/strawberry-perl-5.32.1.1-64bit-PDL/perl/site/lib/MSWin32-x64-multi-thread C:/strawberry-perl-5.32.1.1-64bit-PDL/perl/site/lib C:/strawberry-perl-5.32.1.1-64bit-PDL/perl/vendor/lib C:/strawberry-perl-5.32.1.1-64bit-PDL/perl/lib) at (eval 422) line 7. BEGIN failed--compilation aborted at (eval 422) line 7.

To practice examples on http://pdl.perl.org/?page=FirstSteps I again tried installing PDL::Graphics::Simple

C:\strawberry-perl-5.32.1.1-64bit-PDL>cpanm PDL::Graphics::Simple --> Working on PDL::Graphics::Simple Fetching http://www.cpan.org/authors/id/Z/ZO/ZOWIE/PDL-Graphics-Simple-1.005.tar.gz ... OK Configuring PDL-Graphics-Simple-1.005 ... OK Building and testing PDL-Graphics-Simple-1.005 ... FAIL ! Installing PDL::Graphics::Simple failed. See C:\strawberry-perl-5.32.1.1-64bit-PDL\data.cpanm\work\1621510604.10224\build.log for details. Retry with --force to force install it.

but it fails. Using --force however installs but using it in program fails:

pdl> use PDL::Graphics::Simple pdl> imag (sin(rvals(200,200)+1)) Trying gnuplot (PDL::Graphics::Gnuplot)...PDL::Graphics::SImple: Gnuplot exists but yours doesn't support either the x11 or wxt terminal Trying pgplot (PDL::Graphics::PGPLOT::Window)...nope Trying plplot (PDL::Graphics::PLplot)...nope Trying prima (PDL::Graphics::Prima)...nope Runtime error: Sorry, all known plotting engines failed. Install one and try again. pdl>

Looking at the error Gnuplot exists but yours doesn't support either the x11 or wxt terminal, I don't know what to do.

How to get over this error and use PDL with strawberry perl? Any help?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/StrawberryPerl/Perl-Dist-Strawberry/issues/26, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAR3PAHMS3TXKALIQUS24TTOUAO7ANCNFSM45G6CNLQ .

sisyphus commented 3 years ago

On Fri, May 21, 2021 at 1:26 AM sisyphus @.***> wrote:

gmake test ... C:/_64/strawberry-5.32.1-PDL/c/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: PLplot.o:PLplot.c:(.text+0x91b59): undefined reference to `c_plshade1' collect2.exe: error: ld returned 1 exit status gmake: *** [Makefile:481: blib\arch\auto\PDL\Graphics\PLplot\PLplot.xs.dll] Error 1

Seems that "c_plshade1" has been deprecated. See https://github.com/PDLPorters/pdl-graphics-plplot/issues/6

IIUC, the function would have been available if Strawberry had built the PLplot library with -DPL_DEPRECATED . But that wasn't done.

I have strawberry-perl-5.28.0.1-64bit-PDL.zip, and its PLplot library does provide "c_plshade1". So the simplest thing for you to do, is to replace your current c/bin/libplplot.dll and c/lib/lib/plplot.a with the same files from the 5.28.0 strawberry PDL distro. Also you need to replace the c/include/plplot directory with the same directory from the 5.28.0 strawberry PDL distro. (The PLplot installation that ships with the 5.30.0 strawberry PDL distro might also be ok .... I haven't tested that.)

Of course, you'll also need to do the things I outlined in my previous post

That worked fine for me, despite some noisy tests (compiler warnings, and a couple of generated files that couldn't be unlinked):

All tests successful. Files=3, Tests=253, 51 wallclock secs ( 0.06 usr + 0.01 sys = 0.08 CPU) Result: PASS

sumanstats commented 3 years ago

Thank you for looking into the issue. I hope strawberry would look into these intricacies and make it easier for a beginner who want to start with scientific programming in perl.

sisyphus commented 3 years ago

On Sat, May 29, 2021 at 2:30 PM Suman Khanal @.***> wrote:

Thank you for looking into the issue. I hope strawberry would look into these intricacies and make it easier for a beginner who want to start with scientific programming in perl.

Yes, it would be nice if they could re-build the PLplot library with -DPL_DEPRECATED and maybe, for the PDL distro, they could also set the PLPLOT_LIBDIR and PLPLOT_INCDIR environment variables in portableshell.bat.

But that won't help the Makefile.PL locate the plplot dll. That should be fixed by the PDL::Graphics::PLplot maintainer but, until that happens, the person wanting to build PDL::Graphics::PLplot is the one who is probably going to have to hack the Makefile.PL

Maybe, if you're lucky, the Strawberry developers will do that hacking and also then provide PDL::Graphics::PLplot in the distro ..... but I'm not sure how much trouble they want to (or ought to) go to.

It will be interesting to see what the Strawberry Perl releases of their perl-5.34.0 distros actually contain.

Cheers, Rob

zmughal commented 2 years ago

Please try PDL-Graphics-PLplot-0.79.

This may have been fixed by https://github.com/PDLPorters/pdl-graphics-plplot/pull/16. You may see an issue with interactive plotting, but plotting to files should work.

sisyphus commented 2 years ago

A straight out cpan -i PDL::Graphics::PLplot failed to install Alien::PLplot, so I broke it up into a few steps:

> set ALIEN_INSTALL_TYPE=share
> cpan -i Alien::cmake3

Then I installed Alien::PLplot the ol' fashioned manual way. (I've no reason to doubt that cpan -i Alien::PLplot would have worked just as well)

Then I installed PDL-Graphics-PLplot-0.79 via the same manual method. (Again, I believe cpan -i PDL-Graphics-PLplot would also have worked.)

The 'gmake test' step produced some noise (see attached plplot_tests.txt) - though I think all of that noise is expected.

plplot_tests.txt

zmughal commented 2 years ago

Thank you for testing that @sisyphus! Yes, that noise is expected from the tests on Windows.

shawnlaffan commented 1 year ago

Testing PDL::Graphics::PLplot with the current 5.36.1 dev release results in test failures.

It looks like the system crashes on test 17 when it tries to call

$pl->shadeplot ($z, $nsteps, BOX => [-1, 1, -1, 1], PALETTE => 'RAINBOW')

Wrapping the code in an eval has no effect.

If I run plplot.t under gdb then all tests pass and the script completes normally. I'm not sure what to make of that.

perl -Mblib t\plplot.t
ok 1 - An object of class 'PDL::Graphics::PLplot' isa 'PDL::Graphics::PLplot'
ok 2 - Simple line plot
ok 3 - Simple line plot with LINEWIDTH specified
ok 4 - Symbol plot
ok 5 - Lines and symbols
ok 6 - Sample layer statistics plot
ok 7 - Setting pagesize
ok 8 - Line plot with gaps (plgapline)
ok 9 - Setting JUSTify = 1
ok 10 - Printing text inside and outside of plot window
ok 11 - Colored symbol plot with key
ok 12 - Colored symbol plot with key: reverse rainbow
ok 13 - Colored symbol plot with key, via low level interface
ok 14 - plgvpd call works correctly
ok 15 - plgvpw call works correctly
ok 16 - 3D color plot, low level interface

Edit - I set the PLPLOT env vars to the relevant share dir before running the build.

shawnlaffan commented 1 year ago

Setting set disable-randomization off in gdb replicates the crash (setting courtesy stackoverflow).

Backtrace below after compiling with gmake OPTIMIZE=-g.

Thread 1 received signal SIGSEGV, Segmentation fault.
0x00007ffeea63b564 in ?? () from C:\ST5EA9~1\data\.cpanm\work\1685253152.33120\PDL-Graphics-PLplot-0.83\blib\arch\auto\PDL\Graphics\PLplot\PLplot.xs.dll
(gdb) bt
#0  0x00007ffeea63b564 in ?? ()
   from C:\ST5EA9~1\data\.cpanm\work\1685253152.33120\PDL-Graphics-PLplot-0.83\blib\arch\auto\PDL\Graphics\PLplot\PLplot.xs.dll
#1  0x00007ffec32f1c3c in perl536!Perl_clear_defarray () from C:\strawberry_5361_gcc13_20230528\perl\bin\perl536.dll
#2  0x00007ffec333ea22 in perl536!Perl_runops_standard () from C:\strawberry_5361_gcc13_20230528\perl\bin\perl536.dll
#3  0x00007ffec33022a4 in perl_run () from C:\strawberry_5361_gcc13_20230528\perl\bin\perl536.dll
#4  0x00007ffec334d95f in perl536!RunPerl () from C:\strawberry_5361_gcc13_20230528\perl\bin\perl536.dll
#5  0x00007ff663b61340 in ?? ()
#6  0x00007ff663b61146 in ?? ()
#7  0x00007fff811026ad in KERNEL32!BaseThreadInitThunk () from C:\WINDOWS\System32\kernel32.dll
#8  0x00007fff819aa9f8 in ntdll!RtlUserThreadStart () from C:\WINDOWS\SYSTEM32\ntdll.dll
#9  0x0000000000000000 in ?? ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)
shawnlaffan commented 1 year ago

FWIW, the backtrace looks similar to the last parts of the one for OpenGL.

shawnlaffan commented 1 year ago

Also FWIW, there are similar test failures under linux with perl 5.37.x so this would not seem to be Strawberry Perl specific. http://matrix.cpantesters.org/?dist=PDL-Graphics-PLplot+0.83

This one, for example, also crashes on test 17: http://www.cpantesters.org/cpan/report/6c4cf676-cc37-11ed-95c7-b1478086ef20

mohawk2 commented 1 year ago

Is this fixed by the vmem change?

shawnlaffan commented 1 year ago

Is this fixed by the vmem change?

No. This strawberry build includes the vmem change.

mohawk2 commented 1 year ago

I'm a bit lost, because it's not at all clear what function it's crashing in (and the same is true of the OpenGL problem, though thanks for capturing the info onto an issue). Would it be possible to tell gdb to break in a plausible function, possibly the actual PLplot plsstrm (one of the first functions called by shadeplot, though might also be called by others), and seeing what bad data is causing the problem?

shawnlaffan commented 1 year ago

I'm sure it's possible but it's best done by someone familiar with the process.

If anyone wants to have a go then the relevant Strawberry perl version can be downloaded from https://github.com/StrawberryPerl/Perl-Dist-Strawberry/releases/tag/dev_5.36.1_20230528_gcc13

shawnlaffan commented 1 year ago

If it helps, the set of patches and other settings used for the build are below.

HAS_BUILTIN_EXPECT is disabled due to stability issues (#85). Would it be possible for HAS_BUILTIN_CHOOSE_EXPR to have similar issues?

https://github.com/StrawberryPerl/Perl-Dist-Strawberry/blob/da78325f3fdaa309589ae159d89776f8894ab29d/share/64bit-5.36.1.1.pp#L57-L86

shawnlaffan commented 1 year ago

Disabling HAS_BUILTIN_CHOOSE_EXPR and d_builtin_choose_expr makes no difference.