AHS
AHS

Reputation: 784

how to load from Python a dll file written in tcl

I have a script written in tcl, that load a dll file. I want to load this file in python. I am not sure if the dll file is written in tcl, but because the tcl file imports it I think it is written in tcl. I have tried to use WinDLL("path_to_dll") but I get that there is no module with the provided name.

Upvotes: 1

Views: 274

Answers (2)

Donal Fellows
Donal Fellows

Reputation: 137807

Python and Tcl have substantially different C APIs; there's no reason at all to expect that a binary library written for one would work with the other. It might be possible to write a library that would use the API of whichever library it is loaded into — from the Tcl perspective, this would involve linking against the Tcl stub library so that there's no nasty hard binding to the API — but I don't know how to do that on the Python side of things and it's definitely highly tricky stuff to attempt to do. More practical would be to have one library that contains a language-independent implementation and then two more that bind that API to a particular language (the binding layer could even be automatically generated with a tool like SWIG, though that doesn't address language impedance issues).

Of course, if you're just wanting to write the library from one language and consume it from another, you can do that. A library is just bytes on disk, after all. It does usually tend to be easier to let specialist tools (compilers, linkers) look after writing libraries though; the data format of a library isn't exactly the simplest thing ever!

Upvotes: 1

schlenk
schlenk

Reputation: 7257

The easiest way would be by using the Tkinter package and its built in Tcl interpreter inside your Python Process.

If it is a Tcl extension dll, it makes no real sense to call it from Python without much setup first.

Upvotes: 2

Related Questions