如何用C++扩展TCL?
我可以编写可编译并用于扩展 TCL 的 C++ 代码(我不是指调用可执行文件)吗?我可以描述一些类、函数并通过调用编译的(.so 或 .a 文件)C++ 代码在我的 TCl 代码中使用它们吗?如果是,请示意性地向我解释一下它是如何完成的。
Can I write a C++ code that can be compiled and used for extending TCL (I don't mean calling an executable file)? Can I describe some classes, functions and use them for in my TCl code by calling the compiled (.so or .a file) C++ code? If yes, then please explain me schematically how it is being done.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
http://cpptcl.sourceforge.net/ 它是 Tcl C API 的 C++ 包装器,使用起来非常方便,有据可查。我是根据我的个人经历来讲述这一点的。
C++/Tcl 是一个可以轻松集成 C++ 和 Tcl 的库。
如果您用两种语言编写程序,您会发现它非常有帮助。
C++/Tcl 库受到 Boost.Python 库的启发,旨在提供类似的接口。
目前,C++/Tcl 库提供以下功能:
支持使用 C++ 模块扩展 Tcl 以及在 C++ 应用程序中嵌入 Tcl。
可以将自由 C++ 函数公开为 Tcl 中的命令。
可以定义类和类成员函数,在 Tcl 中可见,其样式类似于 SWIG 包装器。
可以从 C++ 代码操作 Tcl 列表和对象。
http://cpptcl.sourceforge.net/ It is a C++ wrapper of Tcl C API and very convenient to use, well documented. I tell this from my personal experience.
C++/Tcl is a library that allows to easily integrate C++ and Tcl.
If you write programs in both languages, you will find it to be extremely helpful.
The C++/Tcl library was inspired by the Boost.Python library and was designed to provide a similar interface.
Currently, the C++/Tcl library offers the following features:
Support for both extending Tcl with C++ modules and embedding Tcl in C++ applications.
Possibility to expose free C++ functions as commands in Tcl.
Possibility to define classes and class member functions, visible in Tcl in the style similar to SWIG wrappers.
Possibility to manipulate Tcl lists and objects from the C++ code.
您可以使用 C++ 扩展 TCL。尤其要看看Itcl++ 工具。
You can extend TCL with C++. Especially have a look at the Itcl++ tool.
看看这个问题,它显示了如何在 Windows 下使用 Visual C++ 创建 Tcl 扩展。 Unix 下的过程类似,但您创建的是 Unix .so 库而不是 .dll。
Have a look at this question, it shows how to create an Tcl extension using Visual C++ under Windows. The process under Unix is similar but you create a Unix .so library rather than a .dll.
您可以考虑使用 SWIG 来构建绑定。它不会产生特别惯用的 Tcl 接口(毕竟 Tcl 和 C++ 是相当不同的语言),但它确实允许您非常快速地开始工作。
You might consider using SWIG to build the binding. It doesn't produce a particularly idiomatic Tcl interface (Tcl and C++ being rather different languages after all) but it does allow you to get working very rapidly.