Re: Using a tcl interpreter inside a DLL?



On Nov 29, 12:43 pm, jmbussat <jmbus...@xxxxxxxxx> wrote:
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 |
|______________________________________________________________________|



This is more appropriate for a modern Tcl Interpreter.

if (Tcl_Init(interp) != TCL_OK) {
fprintf(STDERR,
"Tcl_Init: %s",
Tcl_GetStringResult(interp));
return;
}
.



Relevant Pages

  • Tcl thread local storage memory problem
    ... I am working on an application that originally uses one thread, TCL ... and the C-library to initialize an interpreter and executing standard ... InitializeThreadLocalStorage(); /*If no threads, initialize ... able to get Tcl thread local storage ...
    (comp.lang.tcl)
  • Re: File data format
    ... This is how I always look at data processing with Tcl: ... then let the very effecient tcl interpreter do the parsing. ... Create procs that match the data keys. ... date, commit, and compile, that matched the same signature, then your ...
    (comp.lang.tcl)
  • Re: No argv, argc for worker thread
    ... I expected that a Tcl interpreter started in any manner would accept options ... This is how the interpreter works with command line options ... a "main" script processes command line ...
    (comp.lang.tcl)
  • Re: Tcl/TK is indeed dying
    ... A fat Tcl interpreter has impact to all wanting to see Tcl linked to ... other software and embedded in hardware, because fatness make it less ...
    (comp.lang.tcl)
  • Re: looking for tcl based Cisco like command line interface
    ... TinyTcl and Jim would be fine to save resources, but first is missing some newer tcl sub-/commands and later has no exec-command at all. ... Only want to install one single tcl/etcl/tclkit interpreter and a single tcl script. ... Funny, the cli can be run from any computer remote,using snmp get/get-next/set for communication to the network device, therefore got a remote console program too. ... extreme environments) based on ARM or Coldfire processor using Debian Linux/ucLinux should be extended with a CLI that is similar in behaviour, handling and naming conventions to the well known cisco command line interface (several user-visible application-specific commands, along with a help, different management operation levels like "enable", "config", line driven only, tab expansion, no special graphics or ascii terminal commands) ...
    (comp.lang.tcl)