Updated 2014-01-20 17:44:51 by RLE

[Add comments regarding examples of building tcl and tcl based programs in this development environment.]

http://groups.google.com/group/comp.lang.tcl/msg/470881fc423d4d4d is a message posted to comp.lang.tcl by Michael Reichenbach, where he describes the steps he took to build some C++ code that accesses the Tcl library.

The highlights are:

  1. File -> new project -> name: Foo -> win32 console application -> dll
  2. Tools -> Options -> VC++ Directorys -> Include Files -> added C:\Tcl\include
  3. C++ -> precompiled headers -> Not Using Precompiled Headers
  4. Library files -> C:\Tcl\lib
  5. Project settings -> Configuration Properties -> Linker -> Input -> Additional Dependencies -> added c:\tcl\lib\tclstub84.lib
  6. use this source (my mistake was to use the #define after #include) (without the extern "C" its also not working, you will get error message while % load Foo.dll, it says cant find Foo_Init procedure)
 #define USE_TCL_STUBS 1

 #include <tcl.h>
 #include <stdio.h>

 extern "C"
        __declspec(dllexport) int Foo_Init(Tcl_Interp* interp);


 static int fooCmd(ClientData clientData, Tcl_Interp *interp, int objc,
 Tcl_Obj * CONST objvg) {
        printf("called with %d arguments\n", objc);
        return TCL_OK;


 int Foo_Init(Tcl_Interp *interp) {
        if (Tcl_InitStubs(interp, "8.1", 0) == NULL) {
                return TCL_ERROR;
        printf("creating foo command");
        Tcl_CreateObjCommand(interp, "foo", fooCmd, NULL, NULL);
        return TCL_OK;


  1. Debug -> change to Release
  2. Build -> Build solution -> compiles without any errors -> in project folder under release is File Foo.dll with ~6 kb

If you can provide more examples of building using this environment, please add the information to this page.