【发布时间】:2015-03-06 15:22:15
【问题描述】:
我有一个 Tcl 的 C 扩展,其中定义了命令 mytest。扩展名编译正确(我在 Linux 上,扩展名是 *.so)。例如,我可以启动 tclsh 并像这样使用它:
$ tclsh
% load /path/extension.so
% mytest abc
...
但是,如果我创建一个包含以下内容的文件 myscript.tcl:
load /path/extension.so
mytest abc
然后我得到错误:
$ tclsh myscript.tcl
invalid command name "mytest"
while executing
"mytest abc"
(file "myscript.tcl" line 2)
我在 Ubuntu 14.04 上使用 bash。 Tcl 8.6。
编辑 1:我的问题/问题是我想将 tclsh 与脚本一起用作参数 - 此脚本应正确加载扩展,以使 mytest 和其他已实现的函数正常工作。
编辑 2:嗯,如果我在 tcl shell 中使用命令“source myscript.tcl”,结果是一样的。如果我为 myscript.tcl 使用绝对路径,错误仍然相同 --- “加载”会在没有警告的情况下执行,但我不确定,因为我得到 invalid command name “mytest”。可能问题出在作用域上,但是当交互式使用 tclsh 时它可以正常工作。
【问题讨论】:
-
问题到底是什么?
-
在 tcl shell 中获取文件时会发生什么?