windows 我的环境中使用的任何 tcl api (Tcl_*) 的分段错误

Segmentation fault with any tcl api (Tcl_*) used in my environment in windows

我有一个链接到 tcl 静态库的 dll (tcl84tsx.lib)。现在需要时,我从我的 exe 动态加载这个 dll。我的 exe 调用了 dll 的一些函数,而 dll 的那些函数正在调用 tcl 库的函数。

我收到从 dll 调用的任何 tcl 函数的分段错误。

以下是首先调用Tcl函数的dll部分代码:

if (mTclInterp == NULL) {
    mTclInterp = Tcl_CreateInterp();
    Tcl_Init(mTclInterp);
}   

这里我通过调用 tcl libraryTcl_CreatInterp 函数在 C++ 中创建 Tcl interpreter。我在这条线上遇到 segmentation 错误。请注意,在 linux 中一切正常,但我在 windows 中遇到了这个问题。

请让我知道我做错了什么。

对 Tcl 库的第一次调用应该是 Tcl_FindExecutable Tcl_Main (当你想要这样做时;几乎是第一件事它在内部调用 Tcl_FindExecutable)。对 Tcl_FindExecutable 的调用会初始化库本身,尤其是与内存管理和文件系统访问层相关的部分。

初始化库后,您可以调用 API 的其余部分,其中大部分需要解释器上下文句柄,因此 Tcl_CreateInterp 将是早期调用。