C Interface question. RE: 8.0 vs 8.4
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.tcl archive

C Interface question. RE: 8.0 vs 8.4

From: <bbailey@raytheon.com>
Date: Sun Apr 16 2006 - 16:15:26 CEST

Hello All,

I am currently working to re-work a C app with a Tcl/Tk UI. It had been
built on Tcl/Tk 8.0 and I intend to use 8.4.12. My problem comes when I
attempt to execute the compiled C app. When built and run under 8.0, it
works fine. However, I get an error in the function Tcl_Init when built
and run under 8.4.12.

I use the standard Windows Tcl/Tk install programs in both cases. In
order to isolate the problem, I stripped all the code but the init
routines and supplied a simple script to invoke. I compile the code as
follows (MS VS 2003):

For 8.4.12:

cl test.cpp /Ic:\win32app\tcl\include libc.lib kernel32.lib user32.lib
wsock32.lib advapi32.lib mpr.lib winspool.lib netapi32.lib
c:\win32app\tcl\lib\tk84.lib c:\win32app\tcl\lib\tcl84.lib
/NODEFAULTLIB:library

For 8.0:

cl test.cpp /Ic:\win32app\tcl\include libc.lib kernel32.lib user32.lib
wsock32.lib advapi32.lib mpr.lib winspool.lib netapi32.lib
c:\win32app\tcl\lib\tk80vc.lib c:\win32app\tcl\lib\tcl80vc.lib
/NODEFAULTLIB:library

The simple code itself:

_______________________________________________

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

int main(void) {

  Tcl_Interp *interp;

  interp = Tcl_CreateInterp();

   if (Tcl_Init(interp) == TCL_ERROR) {
     printf("Error initing Tcl");
     return TCL_ERROR;
   }

   if ((Tk_Init(interp) == TCL_ERROR)) {
     printf("Error initing Tk");
     return TCL_ERROR;
   }

   if (Tcl_EvalFile (interp, "c:\\ben\\test\\test\\test.tcl"))
   {
       fprintf(stderr, "Error in script (%s):%s\n",
"c:\\ben\\test\\test\\test.tcl", interp->result);
       return(1);
   }

/* Invoke the Tk objects */
   Tk_MainLoop();
   Tcl_DeleteInterp(interp);
   return TCL_OK;
}

________________________________________________________

Any insight would be greatly appreciated.

Ben

<br><font size=2 face="sans-serif">Hello All,</font>
<br>
<br><font size=2 face="sans-serif">I am currently working to re-work a
C app with a Tcl/Tk UI. &nbsp;It had been built on Tcl/Tk 8.0 and I intend
to use 8.4.12. &nbsp;My problem comes when I attempt to execute the compiled
C app. &nbsp;When built and run under 8.0, it works fine. &nbsp;However,
I get an error in the function Tcl_Init when built and run under 8.4.12.</font>
<br>
<br><font size=2 face="sans-serif">I use the standard Windows Tcl/Tk install
programs in both cases. &nbsp;In order to isolate the problem, I stripped
all the code but the init routines and supplied a simple script to invoke.
&nbsp;I compile the code as follows (MS VS 2003):</font>
<br>
<br><font size=2 face="sans-serif">For 8.4.12:</font>
<br>
<br><font size=2 face="sans-serif">cl test.cpp /Ic:\win32app\tcl\include
libc.lib kernel32.lib user32.lib wsock32.lib advapi32.lib mpr.lib winspool.lib
netapi32.lib c:\win32app\tcl\lib\tk84.lib c:\win32app\tcl\lib\tcl84.lib
/NODEFAULTLIB:library</font>
<br>
<br><font size=2 face="sans-serif">For 8.0:</font>
<br>
<br><font size=2 face="sans-serif">cl test.cpp /Ic:\win32app\tcl\include
libc.lib kernel32.lib user32.lib wsock32.lib advapi32.lib mpr.lib winspool.lib
netapi32.lib c:\win32app\tcl\lib\tk80vc.lib c:\win32app\tcl\lib\tcl80vc.lib
/NODEFAULTLIB:library</font>
<br>
<br><font size=2 face="sans-serif">The simple code itself:</font>
<br>
<br><font size=2 face="sans-serif">_______________________________________________</font>
<br>
<br><font size=2 face="sans-serif">#include &lt;stdio.h&gt;</font>
<br><font size=2 face="sans-serif">#include &lt;tk.h&gt;</font>
<br><font size=2 face="sans-serif">#include &lt;tcl.h&gt;</font>
<br>
<br>
<br><font size=2 face="sans-serif">int main(void) {</font>
<br>
<br><font size=2 face="sans-serif">&nbsp; Tcl_Interp &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; *interp;</font>
<br>
<br>
<br><font size=2 face="sans-serif">&nbsp; interp = Tcl_CreateInterp();</font>
<br>
<br>
<br><font size=2 face="sans-serif">&nbsp; &nbsp;if (Tcl_Init(interp) ==
TCL_ERROR) {</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp;printf(&quot;Error
initing Tcl&quot;); </font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp;return TCL_ERROR;</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp;} &nbsp;</font>
<br>
<br><font size=2 face="sans-serif">&nbsp; &nbsp;if ((Tk_Init(interp) ==
TCL_ERROR)) {</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp;printf(&quot;Error
initing Tk&quot;);</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp;return TCL_ERROR;</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp;}</font>
<br>
<br>
<br><font size=2 face="sans-serif">&nbsp; &nbsp;if (Tcl_EvalFile (interp,
&quot;c:\\ben\\test\\test\\test.tcl&quot;))</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp;{</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp;fprintf(stderr,
&quot;Error in script (%s):%s\n&quot;, &quot;c:\\ben\\test\\test\\test.tcl&quot;,
interp-&gt;result);</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp;return(1);</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp;}</font>
<br>
<br>
<br><font size=2 face="sans-serif">/* Invoke the Tk objects */</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp;Tk_MainLoop();</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp;Tcl_DeleteInterp(interp);</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp;return TCL_OK;</font>
<br><font size=2 face="sans-serif">}</font>
<br>
<br><font size=2 face="sans-serif">________________________________________________________</font>
<br>
<br><font size=2 face="sans-serif">Any insight would be greatly appreciated.</font>
<br>
<br><font size=2 face="sans-serif">Ben</font>
Received on Sun Apr 30 03:13:26 2006