如何将用 C++ 编写的后端与 tcl/tck 用户界面连接起来?

How to connect backend writtern in c++ with tcl/tck user interface?

我看到了头文件cpptcl.h。合法吗?另外,我在哪里可以找到一个很好的快速入门示例。我正在使用 tcl/tk 设计用户界面,并希望通过分叉 C++ 代码来调用脚本。

How to connect back-end written in c++ with tcl/tk user interface?

您的问题是operating system specific. Because (on many, but not all, OSes) any software application could be made of two (or more) processes cooperating by using inter-process communication facilities, and that approach (which is often implied by using the "back-end" word) has the huge advantage of taking profit from process isolation. Read more about software pipelines, about pipes and sockets. They might be available on your target OS. For a good overview on operating systems, I strongly recommend reading Operating Systems: Three Easy Pieces(可免费下载)。

如果您正在为 Windows 编写代码,请研究并了解 man 页面中引用的 WinAPI. If you are coding for Linux, study its programming API by reading ALP and looking into syscalls(2) and every system call。这两份文件都对编码 inter-process 通信很有用。

您可以编写一个 executable application, by linking a Tcl/Tk library (or code) with your core, application specific, C++ code, but if you do that, you won't speak of any back-end (or front-end), but of the application-specific layer and GUI user-interface (abstraction) layer 代码。

最后,Tcl/Tk 对于 GUI 开发来说似乎已经过时了。今天,一个好的 C++ GUI toolkit is Qt,它(在功能和界面外观质量方面)优于 Tcl/Tk。

I have seen a library cpptcl.h.

那是不是一个library, but a header file (for the C & C++ preprocessor) declaring the interface of some library. I guess that the corresponding library would be a dynamically-linked库,例如一些 lib*.so ELF shared object on Linux, or some *.dll DLL 于 Windows。

Is it legit

我想你是说 "is it legitimate"?当然是的。或者 "conforming to rules" (那么当然是)。您可以询问该图书馆的法律地位,而此类问题的正确措辞是询问其 software license. Tcl/Tk are open source software with some BSD license

where can I find a good quick start example for the same.

Tk 和 Qt 都有 优秀 文档(您应该 阅读 ...)。 Tk 的文档令人印象深刻(Qt 的文档也是如此)。我建议阅读 Tk tutorial first (and if you choose Qt, read first its Getting Started with Qt documentation). Most GUI software involve some event loop (which is provided by Qt and probably also by Tk). You probably should have callbacks (and Qt uses signals and slots) 从事件循环到应用层的 C++ 函数。