You have to stop thinking about Tcl and Expect in terms of DLLs only: both the Tcl DLL and Expect DLL implement core functionality of the respective pieces of software but are not completely self-contained:
- The Tcl interpreter relies on a set of library files which are (dynamically) loaded off the filesystem. These files include (but are not limited to) encoding files, timezone information files and the so-called "core packages", with one example being
http
.
- The Expect package, being a regular Tcl package, relies on the presense of at least a special "index file" (
pkgIndex.tcl
) which "knows" how to properly load and initialize the DLL containing the package's core functionality, and which actually interfaces the package to the Tcl's package loader.
So, to make all this work, you roughly have to follow this checklist:
Ensure the Tcl interpreter you are embedding in your code is properly initialized, and so it's able to load external packages.
Place the complete Expect package into one of the places your embedded interpreter expects to find external packages.
Be sure to read this, this and this to understand how the packaging machinery works and how the special global variable auto_path
is initialized.
Call package require Expect
in those scripts in your program which require the presence of the Expect package to get it loaded.
Alternatively, you might perform proper calls to Tcl C API on your embedded interpreter to load the Expect package's DLL directly, so it will be available to the script you execute later right away.
Yet another alternative (which is trickier to get right for a starter) is to employ the so-called "basekit" or "tclkit" — a Tcl library which has certain Tcl packages included within it using a virtual file system, so that these packages could be loaded at runtime off that VFS. These *kits are cool but mastering creation of a proper one is harder than just embedding a "regular" interpreter plus a regular package distributed with the main program as a set of files.
One special note: I'm not sure the license of the ActiveTcl™ product allows ripping off various parts of it and using them in your product. IANAL but I suspect you might be violating that license's terms. To be on the safe side, build both Tcl and Expect from the source — that's not hard.
package require Expect
? – Johannes Kuhn