windowsperltclstrawberry-perl

Strawberry Perl: can't build Tcl module


I am having trouble building the Tkx module with Strawberry Perl on a Windows 10 platform. It is failing on the Tcl dependency. The errors are:

Tcl.o:Tcl.c:(.text+0x65): undefined reference to `__imp_Tcl_GetStringFromObj'
Tcl.o:Tcl.c:(.text+0x15e): undefined reference to `__imp_Tcl_ListObjGetElements'
Tcl.o:Tcl.c:(.text+0x1fb): undefined reference to `__imp_Tcl_GetStringFromObj'
Tcl.o:Tcl.c:(.text+0x29a): undefined reference to `__imp_Tcl_GetByteArrayFromObj'
Tcl.o:Tcl.c:(.text+0x4bf): undefined reference to `__imp_Tcl_NewStringObj'
Tcl.o:Tcl.c:(.text+0x538): undefined reference to `__imp_Tcl_NewDoubleObj'
Tcl.o:Tcl.c:(.text+0x58f): undefined reference to `__imp_Tcl_NewStringObj'
Tcl.o:Tcl.c:(.text+0x5d7): undefined reference to `__imp_Tcl_NewByteArrayObj'
Tcl.o:Tcl.c:(.text+0x621): undefined reference to `__imp_Tcl_NewListObj'
Tcl.o:Tcl.c:(.text+0x643): undefined reference to `__imp_Tcl_ListObjAppendElement'
Tcl.o:Tcl.c:(.text+0x6a1): undefined reference to `__imp_Tcl_NewObj'
Tcl.o:Tcl.c:(.text+0x6af): undefined reference to `__imp_Tcl_ListObjAppendElement'
Tcl.o:Tcl.c:(.text+0x6d1): undefined reference to `__imp_Tcl_NewIntObj'
Tcl.o:Tcl.c:(.text+0x786): undefined reference to `__imp_Tcl_NewByteArrayObj'
Tcl.o:Tcl.c:(.text+0x839): undefined reference to `__imp_Tcl_WrongNumArgs'

and many, many more similar errors. I searched, but I found nothing even close. The Strawberry Perl version is 5.26.4 and I did the recommended

cpan Tkx

I get the same errors when trying to build the Tcl module by itself with:

cpan Tcl

I have ActiveTcl installed, but Strawberry Perl doesn't seem to see it.

How do I get a working Tcl module for Strawberry Perl?


Solution

  • I managed to get the build to work on Strawberry Perl 5.26. (The binutils package bundled with 5.24 seems to have a bug that makes it not recognize the .lib files from Tcl.)

    The issue seems to be

    Warning (mostly harmless): No library found for -ltcl86
    

    in the vanilla build, because that library is definitely required. In my C:\ActiveTcl\lib there is indeed no tcl86.lib, but there is a tcl86t.lib.

    So ...

    1. Run cpan. This drops you in the cpan shell.
    2. Run look Tcl. This downloads the Tcl module (if necessary) and drops you in the cmd shell in the build directory.
    3. Edit Makefile.PL using your favorite editor.
    4. Around line 183 there should be a line saying:

              $libpath .= " -ltcl$buildtype$tclver";
      

      Add another line after it:

              $libpath .= "t";
      
    5. Save and exit your editor.

    6. Run perl Makefile.PL. It should now be using -ltcl86t.
    7. Type exit in the cmd shell to get back to the cpan shell.
    8. Run install Tcl. This should go through successfully.
    9. Type exit again to exit the cpan shell.