Krouitch
Krouitch

Reputation: 626

Is there an alternative to the load command to import binary Tcl package

I am using a commercial tool interfaced with an homebrew tclsh(Synopsys EDA).

In their version, they removed the load command. Thus I cannot use third party libraries (Graphviz library in my case).

I wonder if there is a another way to import binary files (.so files)

Upvotes: 2

Views: 770

Answers (1)

Donal Fellows
Donal Fellows

Reputation: 137567

The only command in standard Tcl that brings in a dynamic library is load. (OK, package require can do too, but that's because it can call load inside.) Without that command, you only have options like statically linking your own code in and creating the commands in the Tcl_AppInit function, but that's really unlikely to work if you're already using someone else's code that's already done that sort of thing.

The easiest approach might be to run a normal tclsh as a subprocess via exec tclsh script.tcl (run and wait for termination) or open |tclsh r+ (open pipeline). If they've not turned off those capabilities as well; you might be running in a safe interpreter where all those things are systematically disabled. I don't know of any way to break out of a standard safe interpreter (the mechanism for locking them down errs on the side of caution) so if that's the case, you'll just have to save the data you want to a file somewhere (by any mechanism that works; safe interpreters also can't touch the filesystem at all by default though that is often profiled back in in protected ways) and use a completely separate program to work with it.

Upvotes: 1

Related Questions