Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2022-06-20
15:21 • Closed ticket [a55872c242]: tcl8.7 on windows: linking against stubs library is ... artifact: e6c0d7fce9 user: jan.nijtmans
15:20
Fix [a55872c242]: tcl8.7 on windows: linking against stubs library is now required in 8.7. No longer... check-in: d7052c5f73 user: jan.nijtmans tags: core-8-branch
14:15 • Ticket [a55872c242] tcl8.7 on windows: linking against stubs library is now requ... artifact: cff325ddad user: ralfixx
11:59 • Ticket [a55872c242]: 3 changes artifact: 229d1b36af user: jan.nijtmans
11:58 • Pending ticket [a55872c242]. artifact: efd0e3ab13 user: jan.nijtmans
11:55
Fix [a55872c242]: tcl8.7 on windows: linking against stubs library is now required in 8.7. If the Tc... closed check-in: 3483c7eafd user: jan.nijtmans tags: bug-a55872c242
11:29 • Ticket [a55872c242] tcl8.7 on windows: linking against stubs library is now requ... artifact: bb3744b19b user: jan.nijtmans
10:45 • Ticket [a55872c242]: 4 changes artifact: 939cf3e827 user: oehhar
10:37 • New ticket [a55872c242]. artifact: 6999bb2960 user: ralfixx

tcl8.7 on windows: linking against stubs library is now required in 8.7

Closed / Fixeda55872c2429bea123139d3f2bd25182a2d6c78f7Created 4 years agoUpdated 4 years ago
Descriptionplain2022-06-20 10:37:19
Taking the minimal tclsh example from
    https://wiki.tcl-lang.org/page/Building+a+custom+tclsh
    /* t.c */
    #include <tcl.h>
    int AppInit(Tcl_Interp *interp) {
      if(Tcl_Init(interp) == TCL_ERROR) return TCL_ERROR; 
      Tcl_SetVar(interp,"tcl_rcFileName","~/.wishrc",TCL_GLOBAL_ONLY);
      return TCL_OK;
    }
    int main(int argc, char *argv[]) {
      Tcl_Main(argc, argv, AppInit);
      return 0; 
    }
    /* End of file */

Linking on windows now requires linking against the TCL stubs library in
8.7, where this was not required in 8.6.

This is due to a change in the Tcl_Main macro on windows, which now
includes a call to Tcl_SetPanicProc(Tcl_ConsolePanic) in tcl.h:

   #define Tcl_Main(argc, argv, proc) Tcl_MainEx(argc, argv, proc, \
	    ((Tcl_SetPanicProc(Tcl_ConsolePanic), Tcl_CreateInterp)()))

where 'Tcl_ConsolePanic' is #defined NULL on Linux, but a real function
on Windows, which is only available in the stubs library.

  Linking against 8.7:
    $ cl /nologo /Fet.exe t.c -Itcltk87/include tcltk87/lib/tcl87.lib
    t.c
    t.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol "Tcl_ConsolePanic" in Funktion "main".
    t.exe : fatal error LNK1120: 1 nicht aufgelöste Externe

    adding tcltk87/lib/tclstub87.lib to the link line => success.
    $ cl /nologo /Fet.exe t.c -Itcltk87/include tcltk87/lib/tcl87.lib tcltk87/lib/tclstub87.lib
    t.c
    => success

  Linking against 8.6:
    $ cl /nologo /Fet.exe t.c -Itcltk86/include tcltk86/lib/tcl86.lib
    t.c
    => success

Not sure if this was intentional, but it probably should be documented
in the Tcl_Main manpage, which already reads

    Programs that call Tcl_Main must be linked
    against the standard Tcl library.
Referenced by3
  • d7052c5f73Fix [a55872c242]: tcl8.7 on windows: linking against stubs library is now required in 8.7. No longer required now (with this change) if the Tcl lib is static. check-in2022-06-20 15:20:13
  • efd0e3ab13Pending ticket [a55872c242]: tcl8.7 on windows: linking against stubs library is now required in 8.7 plus 4 other changes ticket2022-06-20 11:58:19
  • 3483c7eafdFix [a55872c242]: tcl8.7 on windows: linking against stubs library is now required in 8.7. If the Tcl library is static (.lib/.a) then the stub library is (with this fix) no longer necessary. If the Tcl library is a dll, document that the stub library is now necessary. check-in2022-06-20 11:55:29
oehharwiki2022-06-20 10:45:25

Thank you, Ralf,

IMHO, this is a bug. IMHO, it should work by one of:

  • static build
  • link to tcl lib
  • link to tcl stubs lib

As you report, the tcl lib is not sufficient. The stubs lib is required.

Thank you, Harald

jan.nijtmanswiki2022-06-20 11:29:14

This change is due to TIP #425. Tcl_ConsolePanic() needs to be static, because the panicproc could - theoretically - be called even after bringing down tcl.dll. The only way I see to fulfill this requirement is putting Tcl_ConsolePanic() in the stub library, then we are sure it is linked statically in the executable so it will always be available.

jan.nijtmanswiki2022-06-20 11:58:19

If the Tcl library is static, the stub library should not be necessary. That's fixed [here]. If the Tcl library is a dll, I don't see a solution without the stub library. So, documented that now.

Ralf, can you live with that ;-)

jan.nijtmanswiki2022-06-20 11:59:43

Fix is really [here] (previous link just links back to this ticket....)

ralfixxplain2022-06-20 14:15:28
Yes, of course I can live with that ;-)
jan.nijtmanswiki2022-06-20 15:21:30

Changes committed now. Thanks!

Log in (anonymous is fine) to add a comment.