Version 8 of Dynamic Libraries in Tcl

Updated 2003-09-09 15:50:47

Purpose: collect information, pointers, etc. regarding issues relating to Tcl and dynamic libraries.

Dynamic libraries - in Windows known as DLLs and in Unix often called shared libraries - are bodies of C code compiled and linked in a manner that make it possible for the code to be read into memory and made a part of running processes.

In Tcl, if the appropriate C code is provided, and the code is compiled properly, one can make use of Tcl's load command to load a dynamic library into an interpreter creating one or more new tcl commands.

When configuing tcl, one seems to need to make certain that one specifies --enable-shared and not specify --disable-load .

Anyone know why the flags are two different words? Is shared and load really two different conditions?

DGP Yes, those configuration options specify two different things. --enable-shared (default) vs. --disable-shared determines whether or not the Tcl library you build is a shared library or a static library. --enable-load (default) vs. --disable-load determines whether or not the Tcl library you build supports a working load command.

LV When you say "[...] supports a working load command", do you mean that --disable-load results in a Tcl library which does not recognize load as a valid command?

DGP No. When a --disable-load configuration of the Tcl library is built, it contains a load command that is the functional equivalent of the command [error "dynamic loading is not currently available on this system"]

LV In other words, when building a Tcl extension, that --enable-load/--disable-load flag probably won't be relevant, and may not even be recognized. However, the --enable-shared/--disable-shared , at least if present, would indicate that the extension (or, in the case of Tcl itself, the base Tcl library) that is generated will be able to be loaded. Right?

DGP I don't understand the rest of your question.

MSW Nope. You can load an extension into a static interpreter, but only if load is functionally available. Whether or not your tcl library is static or dynamic itself doesn't matter.

[Are there any wiki or non-wiki web references which could be inserted here that discuss the approrpriate calls one must make in a library for this?]

[What other wiki and non-wiki references would be useful here?]

What about Direct Shared Library Use for Tcl9?


Category Internals