Taher_Selim
Member level 5
I have downloaded TCL source from here and I can compile it to generate static library in Windows7 using the following command
In the output, I can get
Now I am trying to build my C code (that has TCL embedded):
Because I need to build it in Windows, I am compiling this code in Visual Studio Command Prompt:
But unfortunately, I get always these errors:
If I built TCL as a dymanic library, no errors and I can compile my C code. Does anyone know what could be the problem
Code:
nmake -f makefile.vc OPTS=static INSTALLDIR=path_to_your_install_dir
nmake -f makefile.vc install OPTS=static INSTALLDIR=path_to_your_install_dir
tcl87s.lib - tcldds14s.lib - tclreg13s.lib
Now I am trying to build my C code (that has TCL embedded):
C:
static const char *user_script = "puts \"Hello World ........\"\n";
int my_cmd(Tcl_Interp *interp, const char *arg_str, ...){
char *cmd_str = Tcl_Alloc(256);
va_list ap;
int result;
va_start(ap,arg_str);
vsprintf(cmd_str, arg_str, ap);
result = Tcl_Eval(interp,cmd_str);
Tcl_Free(cmd_str);
return result;
}
int main (int argc ,char *argv[])
{
Tcl_FindExecutable(argv[0]);
Tcl_Interp *myinterp;
printf ("C: Starting ... \n");
myinterp = Tcl_CreateInterp();
if (Tcl_Init(myinterp) != TCL_OK) {
printf("Error: %s\n",Tcl_GetStringResult(myinterp));
return TCL_ERROR;
}
if (my_cmd(myinterp, user_script) != TCL_OK) {
printf("Error: %s\n",Tcl_GetStringResult(myinterp));
return TCL_ERROR;
}
Tcl_DeleteInterp(myinterp);
Tcl_Finalize();
return TCL_OK;
}
Because I need to build it in Windows, I am compiling this code in Visual Studio Command Prompt:
Code:
cl -I"D:\path\to\tcl\include" myCode.c D:\path\to\tcl87s.lib
Code:
error LNK2019: unresolved external symbol __imp__Tcl_Alloc referenced in function ...
error ....................................__imp__Tcl_Free ..................
error ....................................__imp__Tcl_CreateInterp ..................
.........and more errors for other TCL functions.......
If I built TCL as a dymanic library, no errors and I can compile my C code. Does anyone know what could be the problem