开发者

C++/Tk: can we create an executable that would run with out requiering end user to have any special TcL interpriter installed?

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 ad开发者_开发知识库ditional software, are there any entirely static link options for 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.)


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜