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'
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 498 |
Nodes: | 16 (2 / 14) |
Uptime: | 37:17:34 |
Calls: | 9,798 |
Files: | 13,751 |
Messages: | 6,189,336 |