[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:
- File -> new project -> name: Foo -> win32 console application -> dll
- Tools -> Options -> VC++ Directorys -> Include Files -> added C:\Tcl\include
- C++ -> precompiled headers -> Not Using Precompiled Headers
- Library files -> C:\Tcl\lib
- Project settings -> Configuration Properties -> Linker -> Input -> Additional Dependencies -> added c:\tcl\lib\tclstub84.lib
- 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;
}
- Debug -> change to Release
- 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.