Tcl - 如何加载静态链接的 Memchan?
我正在尝试在我的应用程序中使用 Memchan
包。我能够静态编译和链接它。但不幸的是我不知道如何在我的应用程序中加载这个包。
% rs
Internal error detected during start: can't find package Memchan
can't find package Memchan
while executing
"package require Memchan"
我跟踪到了 Memchan2.3
目录中的 pkgIndex.tcl
:
% cat pkgIndex.tcl
package ifneeded Memchan 2.3 [list load [file join $dir libMemchan2.3.so]]
我有两个问题:
- 如何加载静态链接版本
libMemchan2.3.a< /代码>?
- 当调用静态链接库时,是否有一种特殊的语法来调用
package require Memchan
?
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:
- How do I load the statically linked version
libMemchan2.3.a
? - Is there a special syntax for calling
package require Memchan
when one calls a statically linked library?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你有一个静态链接的 memchan 包吗?好吧,这意味着您需要一个不同的包索引,其内容应该是这样的:
load
有一个空的第一个参数,以便考虑静态链接库,但如果没有文件名,则需要第二个参数为了找到初始化函数(将是具有上述值的Memchan_Init
)。或者,只需在脚本开头执行此操作:
这将导致内部
程序包提供
无论如何完成,以便任何未来的程序包都需要Memchans 将立即成功,因为该包已在使用中。
[背景信息]:如您所见,包索引文件实际上非常简单:它只是提供一些说明,说明如果您需要特定版本的特定包,这里有一个脚本可以使其可用。唯一真正的细微差别是
$dir
变量描述了加载文件时包索引文件的位置。You've got a statically linked memchan package? Well, that means you need a different package index, whose contents should be this:
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 beMemchan_Init
with the above value).Alternatively, just do this at the start of your script:
That will cause the internal
package provide
to be done anyway, so that any futurepackage require Memchan
s 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.