Hello all,

I've seen a few email queries on this list (cf.
https://www.nntp.perl.org/group/perl.tcltk/2018/08/msg770.html ) about how
to link to specific versions of the Tcl/Tk frameworks on macOs if you are
using one of the Perl libraries that interface to these frameworks (tkx,
tcl::tk, etc.), and especially if you are deploying a standalone app
bundle.

What has worked for me is to set specific environmental flags at the start
of my main Perl script in my app bundle, which I am currently using in
FileMorph (https://www.codebykevin.com/filemorph.html). Here is the code
snippet I use:

use FindBin qw($Bin);
use File::Basename;
use Config;

BEGIN {
    if ( $Config{osname} eq "darwin" && $ENV{PAR_TEMP} ) {
        my $frameworkpath =
          dirname($Bin) . "/Frameworks/Tcl.framework/Versions/8.6/Tcl";
        $ENV{'PERL_TCL_DL_PATH'} = $frameworkpath;
        $helpdir = dirname($Bin) . '/Resources/FileMorph\\ User\\
Help.help';
    }
    if ( $Config{osname} eq "MSWin32" ) {
        my $frameworkpath = "$Bin/Tcl86/bin/tcl86t.dll";
        $ENV{'PERL_TCL_DL_PATH'} = $frameworkpath;
    }
}

This code has a couple of extra references to PAR/pp environmental
variables, but essentially, on the Mac I use FindBin to locate the
installation of my application, map the Tcl framework within that
installation, and then set that as the library path for Tcl/Tk for Perl to
interface with.

I hope this is helpful to others.

--Kevin

Reply via email to