in reply to Re^6: Perl Tk on a Mac
in thread Perl Tk on a Mac

choroba I got along further with this morning's attempt. I used the old classic perl Makefile.PL; make; make test; and got as far as:

"/Users/nick/perl5/perlbrew/perls/perl-5.40.1/bin/perl" "-I../t" "-MTk +Test" "-e" "checked_test_harness('../xt', 0, '../blib/lib', '../blib/ +arch')" t/*.t t/basic.t .. 1/5


Following the advice in Re: UPDATE 2: Problem Installing Perl-Tk on macOS Monterey (12.6) with Apple M1 chip I renamed the two test files in ./PNG/t and the test suite ran to completion. The output was:

Test Summary Report ------------------- t/listbox.t (Wstat: 0 Tests: 537 Failed: 0) TODO passed: 320-322, 328, 502 t/photo.t (Wstat: 11 (Signal: SEGV) Tests: 1 Failed: +0) Non-zero wait status: 11 Parse errors: Bad plan. You planned 111 tests but ran 1. t/text.t (Wstat: 0 Tests: 415 Failed: 0) TODO passed: 121 t/wm-tcl.t (Wstat: 0 Tests: 315 Failed: 0) TODO passed: 64, 86-87, 154-159, 164-165, 171-178, 221-224 237-239, 264-267, 275-276, 280-283, 300 t/zzScrolled.t (Wstat: 0 Tests: 94 Failed: 0) TODO passed: 52, 66, 80, 94 Files=76, Tests=4257, 62 wallclock secs ( 0.32 usr 0.16 sys + 9.52 c +usr 1.97 csys = 11.97 CPU) Result: FAIL Failed 1/76 test programs. 0/4257 subtests failed. make: *** [test_dynamic] Error 255
I never saw any errors though, so I ran make install and it succeeded.

I was then able to run the hello, world program:

#!/usr/bin/perl use strict; use warnings; use Tk; my $mw = MainWindow->new; $mw->title("Hello World"); $mw->Button(-text + => "Done", -command => sub { exit })->pack; MainLoop;

Hope this helps!


The way forward always starts with a minimal test.

Replies are listed 'Best First'.
Re^8: Perl Tk on a Mac
by choroba (Cardinal) on Mar 21, 2025 at 09:52 UTC
    I was able to skip the two failing tests, too, and install Tk. A small app with a single button worked fine, but the app I needed to run uses PNG images and crashes with a SIGSEGV in the same way as the two tests. I have no idea how to fix that.

    map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

      I am not sure if Tk provides its own libpng or it relies on system-wide-installed libpng. If the case is the latter, then:

      It could be that since apple likes to use its own outdated/modified libraries, it uses its own libpng too which it placed somewhere where the linker finds it first and links with it during Tk compilation which crashes your program. You could perhaps find out what libpng is linked against Tk and where its location is. Perhaps with strace mytkapp? Alternatively observe during the configure stage of the PNG component of Tk, the location of the found libpng.

      Your next step would be to install your own libpng and then mess with the configure of the Makefile of the PNG component of Tk so that it is this one which gets linked instead of the system-wide one. You will want to link statically unless you want to mess with LD_LIBRARY_PATH / DYLD_LIBRARY_PATH (not recommended).

        I might try that next time the client comes. I might also try to persuade my boss I need a Mac myself. But if anyone already having a Mac tried and described their path, I'd be grateful.

        map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]