See UPDATE below:

I've been fighting for the last two days trying to link the (already installed) Tcl.pm module to another Tcl.dll . This is my machine:

Now, no Tcl/Tk is in the permanent Windows Path (and I do not want to have it), no other Tcl/Tk installation is on my machine, only the one above in C:/. I want Tcl.pm to link to this installation, independently to the Tcl installation Tcl.pm was linked to (visible) at the moment of installation. Plus, I do not want to modify permanently my Path. After reading posts everywhere, I was sure the following would work:

use strict; use warnings; BEGIN { print "Starting script on MSWIN\n"; my $pathTCL = "C:/Tcl/bin/tcl86.dll"; print "TCL: " . $pathTCL . "\n"; $ENV{'PERL_TCL_DL_PATH'} = $pathTCL;# showld be the same of: PERL_ +TCL_DLL } use Tcl;

Unfortunately, I get the following, which for me is quite strange...

Starting script on MSWIN TCL: C:/Tcl/bin/tcl86.dll NpLoadLibrary: could not find Tcl library at 'C:/Tcl/bin/tcl86.dll' at + C:/Strawberry/perl/lib/XSLoader.pm line 111. Failed to load Tcl dll! at C:/Strawberry/perl/lib/XSLoader.pm line 111 +. Unable to initialize Tcl at C:/Strawberry/perl/lib/XSLoader.pm line 11 +1. Compilation failed in require at .\wheel.pl line 11. BEGIN failed--compilation aborted at .\wheel.pl line 11.

UPDATE

This is a working solution, but I would like to hear from you if my approach is right. Adding the Tcl bin to $ENV{PATH} seems to make the Tcl installation visible to Tcl.pm. However, I am not a MS Windows man and I am not accustomed to manipulating $ENV in MS Windows, especially within a BEGIN. So, I am wondering if my hack will give me bad surprises (for example Perl is no more in $ENV after the Begin block). Any comment will be very much appreciated.

use warnings; use FindBin qw($Bin); BEGIN { print "Starting script on MSWIN \n"; print "My directory: $Bin\n"; my $pathTclDLL = $Bin . "\\tcltk2\\bin\\tcl86.dll"; my $pathTclBin = $Bin . "\\tcltk2\\bin"; print "TCL DLL: " . $pathTclDLL . "\n"; print "TCL BIN: " . $pathTclBin . "\n"; $ENV{PATH}=$pathTclBin; $ENV{'PERL_TCL_DL_PATH'} = $pathTclDLL; print "Printing ENV\n"; print my $path = $ENV{'PATH'}; } use Tcl;

In reply to Link Tcl to a different tcl.dll on Windows by Takamoto

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.