** Summary ** The most simple example of a [Tcl] [extension]. More examples at [Writing Extensions] contributed by [Ralf Fassel], stubs support added by [George Peter Staplin] ** Description ** ======c /* hello.c */ #include #include #include int hello(/* args ignored */) { printf("hello world"); return TCL_OK; } int Hello_Init(Tcl_Interp *interp) { if (NULL == Tcl_InitStubs (interp, TCL_VERSION, 0)) return TCL_ERROR; printf("this is hello loading"); Tcl_CreateCommand(interp, "hello", hello, NULL, NULL); return Tcl_PkgProvide(interp, "Hello", "1.0"); } /* End of file */ % gcc -shared -o /tmp/hello.so hello.c % tclsh % load /tmp/hello.so ====== For stubs: ======none $ gcc -shared -o hello.so -DUSE_TCL_STUBS hello.c /path/to/libtclstub84.a -lm -Wl,-rpath=/path/to/dir/with/libtcl84.so $ tclsh8.4 % load ./hello.so ====== <> Example