Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I have a fresh installation of ActivePerl 5.22.1 and Tk 804.033 on OS X ElCapitan. Running a simple Tk testing code I get the following error:

Can't load '/Users/xxx/Library/ActivePerl-5.22/lib/auto/Tk/Tk.bundle' +for module Tk: dlopen(/Users/xxx/Library/ActivePerl-5.22/lib/auto/Tk/ +Tk.bundle, 1): Library not loaded: /opt/X11/lib/libX11.6.dylib Referenced from: /Users/xxx/Library/ActivePerl-5.22/lib/auto/Tk/Tk.b +undle Reason: image not found at /usr/local/ActivePerl-5.22/lib/DynaLoader +.pm line 198. at halloworld.pl line 4. Compilation failed in require at halloworld.pl line 4.

PATH is set correctly. I already tried to reinstall Tk with ppm. The module Tk.bundle seems to be in place. Line 4 of the script is use Tk . I am very new to OS X. I used for years Tk on Windows/Linux and now I am trying to run it on Mac with no success. Any help? The Activestate Forum did not answered

Replies are listed 'Best First'.
Re: OS X ElCaptain Activeperl Tk
by kevbot (Vicar) on Jun 16, 2016 at 04:01 UTC
    Do you have Xquartz installed? The Library not loaded: /opt/X11/lib/libX11.6.dylib message makes me think that you might not have it installed.

      Hello kevbot, that was ist!!! THANK YOU! I have a couple of questions, as I couldn't find any answer on the Wen. 1) Why does it need X11 (if Tkx runs without it without problems)? 2) If I deploy the software to other users... will they need to install X11 to?

        Hello Anonymous Monk,

        Tk and Tkx are different implementations. Tkx appears to have support for Aqua and/or X11 while Tk requires X11 (see this thread: building Tk without X11 on mac OS).

        If you are not using a packager and intend to deploy your script simply by providing a copy of the script, the end users will need to have Xquartz and all required perl modules installed. If you wish to give your users a stand-alone executable, you could try to package up your app using PAR::Packer. This thread (Perl/Tk and PAR::Packer on OS X) has a discussion on trying to create a stand-alone executable of a Perl/Tk app; however, the conclusion seems to be that the end users of the executable would still need to have Xquartz installed.

Re: OS X ElCaptain Activeperl Tk
by Marshall (Canon) on Jun 15, 2016 at 17:44 UTC
    Can you show us the actual 4 lines of code that fails? Make the failure code as simple as possible.
    #!usr/bin/perl use strict; use warnings; use Tk;
    should work because Tk comes with AS Perl 5.22. update: what is dlopen?

      I get the same Error with your code (good point to keep it so simple). My code was:

      #!/usr/bin/perl -w # Display Hello World program use Tk; use strict; my $mw = MainWindow->new; $mw->geometry("200x100"); $mw->title("Hello World!!!"); $mw->Label(-text => 'Hello World')->pack(); $mw->Button(-text => "Close", -command =>sub{exit})->pack(); MainLoop;

      Tk was installed with ppm so I really thought I was on the safe side... but no. Do I have to install codeX to make it run? I do not think is the case. I also tried a mini script with Tkx (which comes with Activestate already installed) and it works fine. What can I try?

        I am running a "clean install" of Active State 5.20 for Windows on a laptop - no additional ppm installs. The result is that your script works just fine - no problem. I do not have a Mac, but I've given Tk code before to folks who do and it works fine (although that was before 5.22).

        I confess to being flummoxed at this point.

        Update: Oh, since latest Mac OS'es are linux like, there may be a path problem between this new latest AS installation and the system's idea of Perl? What does Perl -V show?

      dopen: no idea at all!

Re: OS X ElCaptain Activeperl Tk
by $h4X4_|=73}{ (Monk) on Jun 16, 2016 at 08:56 UTC
Re: OS X ElCaptain Activeperl Tk
by Anonymous Monk on Jun 15, 2016 at 22:53 UTC