Calling functions in arbitrary dynamic libraries ================================================ Rev 0.11: Added support for Windows (by Scott Beasley) Rev 0.10: Initial release This package defines commands to make calls through the Unix "dl*" API. The current version has only been tried under Linux, other systems will most likely require changes (on some this may not be feasible at all). There are a number of procs, described as sample calls below: set lib [dynopen file] open a shared library and return a handle for it will return zero if the library cannot be loaded set sym [dynsym $lib funcname] lookup a function, and return a call handle for it will return zero if the named function is not found dynclose $lib closes a shared library (do not call anything in it after this) puts [dynerror] returns last error, if any, and also clears it set result [dyncall $sym args] call the specified function with args as given Passing arguments to the function will require some work (in some cases a lot of work). The idea is to use "binary format ..." to create a binary data structure of the right form. This data structure represents 0..10 integer arguments, passed to the function by dyncall. More functions will need to be added to this package, to make it possible to access, construct, and de-construct complex data structures. Details for this have not yet been worked out (libffi and several other libraries are available, and might be a better way to proceed for complicated use). Code like this has to come with a huge bright red flashing warning sign, saying that it is *trivial* to crash the system with dynlib. Even the test sample crashes, if used in combination with a statically-linked Tcl.