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

60 views
Skip to first unread message

Ralf Fassel

unread,
Jun 16, 2022, 2:11:19 PMJun 16
to
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.

HTH
R'

Harald Oehlmann

unread,
Jun 17, 2022, 2:56:01 AMJun 17
to
Ralf,

I would post a TCL ticket to have the discussion at the right place.
I suppose, this is an unintended side effect.
Harald

Ralf Fassel

unread,
Jun 20, 2022, 6:38:43 AMJun 20
to
* Harald Oehlmann <wort...@yahoo.de>
| Am 16.06.2022 um 20:11 schrieb Ralf Fassel:
--<snip-snip>--
| > Linking on windows now requires linking against the TCL stubs library in
| > 8.7, where this was not required in 8.6.
--<snip-snip>--
>
| I would post a TCL ticket to have the discussion at the right place.
| I suppose, this is an unintended side effect.

[x] done

https://core.tcl-lang.org/tcl/tktview/a55872c2429bea123139d3f2bd25182a2d6c78f7

R'
Reply all
Reply to author
Forward
0 new messages