Re: Using a tcl interpreter inside a DLL?




Hi,

My DLL code contains:

/* Create the interpreter */
interp = Tcl_CreateInterp();
if(interp==NULL){
LDialog_AlertBox("Can't create TCL interpreter");
return;
}

/* Initialize TCL */
if (Tcl_Init(interp) == TCL_ERROR) {
//fprintf(stderr, "Tcl_Init failed: %s\n", interp->result);
sprintf(str,"Tcl_Init failed: %s\n", interp->result);
LDialog_AlertBox(str);
return;
}

The LDialog() functions are basic message boxes from the
application the DLL gets loaded in. I know for sure that
Tcl_CreateInterp() doesn't return NULL and that the
problem is when Tcl_Init gets executed. During my first
attempt, Tcl_Init was complaining that it couldn't find
init.tcl but now that I have defined the environment
variable TCL_LIBRARY, the call to Tcl_Init causes the
application that loads the DLL to say that there has been
an "Access violation".
The application I am using is L-Edit from Tanner EDA (it's
a IC layout editor - it has some basic annoying GUI and
scripting functions that I would like to improve using
Tcl/Tk).

Am I supposed to use Tcl_FindExecutable()? because my Linux
test program doesn't use it. I have tried my code as a standalone
program on Linux but I am going to try to see what happens if I
make a dynamic library and then try to use it in another program.

I'm thinking that I must have to do something else to give some
"space" to tcl for it to work...

Thanks for your help.

On Nov 29, 7:51 am, Donald G Porter <d...@xxxxxxxx> wrote:
jmbussat wrote:
I tried to reuse some Linux based code where I use tcl/tk from inside
a
C program that dynamically creates tcl code that gets interpreted by
the
interpreter (!) but I can't go past the Tcl_Init() step without
crashing my
application.

Is your program missing a call to Tcl_FindExecutable()?

When you say "crash," precisely what do you mean? Do you get
an error message? What is it?

--
| Don Porter Mathematical and Computational Sciences Division |
| donald.por...@xxxxxxxx Information Technology Laboratory |
|http://math.nist.gov/~DPorter/ NIST |
|______________________________________________________________________|

.



Relevant Pages

  • dll load problem
    ... static int fooCmd(ClientData clientData,Tcl_Interp *interp, int ... The dll is successfully loaded when I load it in cygwin. ...
    (comp.lang.tcl)
  • Re: Compiling TCL C++ extension (.so) in cygwin environment
    ... Cao_Init(Tcl_Interp *interp) ... DLLEXPORT int ... Windows compilers usually do not export each and every global symbol ... of a DLL to outside callers. ...
    (comp.lang.tcl)