A T
A T

Reputation: 13826

How to load a dll in Tcl?

What I have tried (running Tcl and Tk 8.6.0 on Windows):

load D:/toot/bar/em.dll
load "D:/toot/bar/em.dll"
load D://toot//bar//em.dll
load "D://toot//bar//em.dll"
load D:\toot\bar\em.dll
load "D:\toot\bar\em.dll"
load D:\\toot\\bar\\em.dll
load "D:\\toot\\bar\\em.dll"

All of which return one of these two errors:

couldn't load library [what I put after 'load']: invalid argument

couldn't load library [what I put after 'load', rendered]: this library or a dependent library could not be found in library path

Upvotes: 2

Views: 8621

Answers (2)

Brian
Brian

Reputation: 33

I have this problem, too,couldn't load library "ChariotExt": invalid argument.

And sovled it by change tcl version x64 to x86.

Upvotes: 1

Donal Fellows
Donal Fellows

Reputation: 137577

Assuming that file exists D:/toot/bar/em.dll returns truea, load D:/toot/bar/em.dll should work. However, it sounds like you've got problems with things (i.e., other DLLs) that the library depends on.

This is a general problem on Windows that has been asked elsewhere on Stack Overflow; the answers there are relevant to this question. You should also be aware that if the DLL has been linked against a specific version of the Tcl DLL (not recommended on Windows for Tcl extensions) then you need to have the same version of Tcl installed as it was linked against. Stub-enabled extensions do not have this problem at all (though they can still run into problems with other required libraries being absent).

It's a shame that the load command doesn't tell you what DLL is missing in its error message, but IIRC the underlying OS API doesn't report it either. You're stuck with using an external tool to diagnose these things…


a Don't worry about backslash/forward-slash issues; Tcl handles those for you.

Upvotes: 1

Related Questions