Re: C/XS interfacing with tcl.pm's tcl interpreter dll?

[email protected] (Jeff Hobbs) Wed, 08 Jun 2011 16:45:32 -0700
Newsgroups perl.tcltk
Message-ID <[email protected]>
On 07/06/2011 11:15 AM, patcat88 wrote:
> I am trying to get access to the C API of the TCL interpreter loaded by
> Tcl.pm in my XS module, on windows. There doesn't seem to be any
> official way to get the final dll path, or HMODULE, of the TCL
> interpreter loaded by Tcl.pm.
>
> My analysis of the situation is that $Tcl::DL_PATH is only a suggestion
> to the XS code, not the final dll name. The XS code checks a few other
> places if $Tcl::DL_PATH failed. From what I understand, Tcl.xs stores
> the dll filename and HMODULE but there is no way to obtain it. I cant
> find any way in TCL the lang, but I know little of it, to get the
> pathname of the tcl dll, closest I found was "info nameofexecutable" but
> thats perl.exe. There is the TCL C TclWinGetTclInstance to get the
> HMODULE, but you need the function pointer to TclWinGetTclInstance
> first, chicken and egg. Also Tcl.pm doesn't store function pointers in
> SVs, so GetModuleHandleEx is useless.

There is no way to do this in Tcl, because there may not be any dll 
(e.g. a static executable, or a starkit or stardll).  This is not an 
issue with Tcl extensions that built against and use Tcl stubs.  You 
should be able to do similar with another Perl XS module, but I've not 
tried it myself or know of anyone who has.

Jeff