Anand
Anand

Reputation: 1122

Tcl - how to load Memchan linked statically?

I am trying to use Memchan package in my application. I was able to compile and link it statically. But unfortunately I don't know how to load this package in my application.

% rs
Internal error detected during start: can't find package Memchan
can't find package Memchan
    while executing
"package require Memchan"

I traced this to the pkgIndex.tcl in Memchan2.3 directory:

% cat pkgIndex.tcl
package ifneeded Memchan 2.3  [list load [file join $dir libMemchan2.3.so]]

I have two questions:

Upvotes: 0

Views: 347

Answers (1)

Donal Fellows
Donal Fellows

Reputation: 137807

You've got a statically linked memchan package? Well, that means you need a different package index, whose contents should be this:

package ifneeded Memchan 2.3 {load {} Memchan}

The load has an empty first argument so that statically-linked libraries are considered, but without the filename, a second argument is needed in order to locate the initialization function (which will be Memchan_Init with the above value).

Alternatively, just do this at the start of your script:

load {} Memchan

That will cause the internal package provide to be done anyway, so that any future package require Memchans will just succeed immediately on the grounds that the package is already in use.


[Background info]: As you can see, a package index file is actually very simple: it just provides some instructions to say that if you need a particular package of a particular version, here's a script to make it available. The only real nuance is that the $dir variable describes the location of the package index file while the file is being loaded.

Upvotes: 1

Related Questions