C++/Tk:我们能否创建一个可执行文件,无需最终用户安装任何特殊的 TcL 解释器即可运行?

发布于 2024-11-17 14:29:17 字数 84 浏览 4 评论 0原文

将 C++/Tk 程序编译为可在其他用户计算机上运行的可执行文件的分步说明是什么,不需要最终用户安装任何其他软件,TCL tk 是否有完全静态的链接选项?

What are step by step instructions for compiling C++/Tk program into executable that would run on other users machines not requiring that end users to install any additional software, are there any entirely static link options for TCL tk?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

转角预定愛 2024-11-24 14:29:17

Tcl 和 Tk 在静态构建时工作得很好;这是受支持的(但不是默认的)配置。只需获取源版本并使用 --disable-shared 配置它们即可确保它们为您构建正确类型的库。

Colin 的回答链接到了您需要了解的有关从应用程序内部使用 Tcl 和 Tk 进行编码的大部分内容,例外,您还需要在调用其中任何一个之前调用 Tcl_FindExecutable其他程序(我假设您没有调用 Tcl_MainTk_Main,它们会为您执行此操作,但让您必须像这样工作分别为 tclshwish)。这是确保 Tcl 库内部配置正确的必要调用,因为它处理初始化编码系统和其他类似的低级细节。

如果您可以像使用 tclsh 或 Wish 一样构建您的程序,并且只需将您的 C++ 代码作为扩展包加载,我会敦促您构建您的代码 启用存根,然后将其全部打包为 starkit/starpack。特别是,starpack 是一个单文件可执行文件,它实际上是 Tcl 和 Tk 的独立二进制发行版以及压缩存档格式的应用程序代码。以这种方式分发应用程序确实相当不错,因为它可以避免将代码放在用户可能无意中破坏的地方,但它并不适合所有情况。 (有一些相关的解决方案也可以包括加密您的代码,但它们仅供商业用途。)

Tcl and Tk work just fine when built statically; this is a supported (but not default) configuration. Just get the source releases and configure them with --disable-shared to ensure that they build the right type of library for you.

Colin's answer links to most of what you need to know about coding to use Tcl and Tk from inside your application, except you also need to call Tcl_FindExecutable before you call any of those other programs (I'm assuming you're not calling Tcl_Main or Tk_Main, which would do that for you but leave you bound to working like tclsh and wish respectively). That's a necessary call to ensure that the Tcl library is internally configured correctly, as it handles initializing the encoding system and other low-level details like that.

If you can structure your program like it works with tclsh or wish and just loading your C++ code as an extension package, I would urge you to build your code stubs-enabled and then package it all as a starkit/starpack. In particular, a starpack is a single-file executable which is effectively a self-contained binary distribution of Tcl and Tk plus your application code in a compressed archive format. It's really rather nice to distribute apps this way as it avoids putting code where users can inadvertently break it, but it's not suitable for everything. (There are related solutions that can include encrypting your code too, but they're commercial-only.)

Saygoodbye 2024-11-24 14:29:17

这是 Tcl 的最初用例,尽管现在不那么常见了。查看布伦特·韦尔奇 (Brent Welch) 书中的这一免费章节,了解不错但过时的介绍(或者购买他的书的第四版以获得更新版本)。另一个简短的摘要位于 Tcl wiki 上的将 Tcl/Tk 添加到 C 应用程序

This was the original use-case for Tcl, though it's not so often done now. Take a look at this free chapter from Brent Welch's book for a good but dated introduction (or buy the 4th edition of his book for a more up-to-date version). Another short summary is at Adding Tcl/Tk to a C application on the Tcl wiki.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文