Re: Extension needs another DLL



On 23 mrt, 13:06, Helmut Giese <hgi...@xxxxxxxxxxxxx> wrote:
Hello out there,
consider the situation where you build a Tcl extension (ext.dll) which
relies on another DLL (3rdparty.dll).
- Your pkgindex.tcl arranges for ext.dll to be loaded.
- When loading, the OS discovers that 3rdparty.dll is also needed and
goes looking for it.

This will work (Windows) as long as the cwd is the same directory as
the one where all files making up your extension are found, but once
you move everything to an appropriate place under .../lib it can
easily fail, if 3rdparty.dll cannot be found anymore.

Is there a remedy? I thought I once figured out a way to kind of
"pre-load" 3rdparty.dll so that it was "present" once ext.dll would
request it. However, I cannot remember how I did it.

[load] seems to not be of any help here, since it wants a Tcl package
and 3rdparty.dll is just a plain ol' DLL which knows nothing about
Tcl. Possible solutions are
- static linking of 3rdparty.dll into ext.dll, which may not be
possible if you don't have sources,
- putting 3rdparty.dll into a place where Windows will surely find it
- but you may not have the priviliges to do so.

Is there a way to solve this? Any idea will be greatly appreciated.
Best regards
Helmut Giese

You could extend the path environment variable for the duration of the
[load] command:

package ifneeded ext "[list set oldpath $::env(PATH)]; \
[list set ::env(PATH) [concat $dir $::Env(PATH)]; \
[list load $dir/ext.dll]; \
[list set ::env(PATH) $oldpath]"

(Well, you get the drift)

Regards,

Arjen
.



Relevant Pages