Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

easy way to hide tcl/tk source code?

1,151 views
Skip to first unread message

Hans

unread,
Jun 18, 2013, 8:10:25 PM6/18/13
to
Hi,

Looks like it's really hard to compile a big tcl project into a single executable file, I tried freewrap, tclpro but always get different problems.

Now I'm thinking is there an easy way which can just compile single tcl files one by one, then I can "source" them in my main tcl program. the only objective I hope to archive now is hiding the code. Can I do it?

thanks!

pal...@yahoo.com

unread,
Jun 18, 2013, 8:59:09 PM6/18/13
to
Create a single file executable "starpack". It really is not that hard. See http://beedub.com/book/4th/Starkit.pdf for a chapter from Welch's book. And of course the wiki has more on the process.

The size of the project should not really matter as long as the files are reasonably organized.

/Ashok

Gerald W. Lester

unread,
Jun 18, 2013, 11:06:27 PM6/18/13
to
ActiveState's TclApp/TclCompiler is the way to go -- TclPro is an ancient
technology.


--
+------------------------------------------------------------------------+
| Gerald W. Lester, President, KNG Consulting LLC |
| Email: Gerald...@kng-consulting.net |
+------------------------------------------------------------------------+

George Petasis

unread,
Jun 19, 2013, 1:38:02 AM6/19/13
to
Στις 19/6/2013 6:06 πμ, ο/η Gerald W. Lester έγραψε:
> On 6/18/13 7:10 PM, Hans wrote:
>> Hi,
>>
>> Looks like it's really hard to compile a big tcl project into a single
>> executable file, I tried freewrap, tclpro but always get different
>> problems.
>>
>> Now I'm thinking is there an easy way which can just compile single
>> tcl files one by one, then I can "source" them in my main tcl
>> program. the only objective I hope to archive now is hiding the
>> code. Can I do it?
>
> ActiveState's TclApp/TclCompiler is the way to go -- TclPro is an
> ancient technology.
>
>

I agree. With TDK you can pack your application in a single executable
and protect source code easily.

http://www.activestate.com/tcl-dev-kit

George

EL

unread,
Jun 19, 2013, 2:54:31 AM6/19/13
to
Hans <han...@gmail.com> wrote:

> Now I'm thinking is there an easy way which can just compile single tcl
> files one by one, then I can "source" them in my main tcl program. the
> only objective I hope to archive now is hiding the code. Can I do it?

You really should have a look at tclkit! This is the way to go for
deployment and it works perfectly. It is well described here:

http://equi4.com/starkit/started.html

Basically you rename the base directory of your project and append the
ending .vfs. Then you rename the script that starts your application to
main.tcl. Then you copy all dependencies to this .vfs directory and extend
auto_path to resolve them from there. Then you download a tclkit (the new
ones are here: https://code.google.com/p/tclkit/) and sdx.kit and run:

tclkit sdx.kit wrap <project>.kit

(with <project> being the name of your .vfs directory without the ".vfs").
That's all!


--
Eckhard

Amit Gupta

unread,
Jun 19, 2013, 3:04:11 AM6/19/13
to
I use starkit and pretty happy with it.

Arjen Markus

unread,
Jun 19, 2013, 3:47:01 AM6/19/13
to
Op woensdag 19 juni 2013 08:54:31 UTC+2 schreef Eckhard Lehmann het volgende:

> You really should have a look at tclkit! This is the way to go for
> deployment and it works perfectly. It is well described here:
>
> http://equi4.com/starkit/started.html
>
> Basically you rename the base directory of your project and append the
> ending .vfs. Then you rename the script that starts your application to
> main.tcl. Then you copy all dependencies to this .vfs directory and extend
> auto_path to resolve them from there. Then you download a tclkit (the new
> ones are here: https://code.google.com/p/tclkit/) and sdx.kit and run:
>
> tclkit sdx.kit wrap <project>.kit
>
> (with <project> being the name of your .vfs directory without the ".vfs").
>
> That's all!
>

Well, this is one complete receipe :). You can also make a standalone executable
by using:

tclkit sdx.kit wrap <project>.exe -runtime tclkit-copy.exe

where "tclkit-copy.exe" is a copy of the tclkit executable (on Windows
this is required to be a different file than the executable you run, IIRC).
You can even build standalone executables in this way for a different
platform - as long as you have the appropriate tclkit executable.

(freewrap has similar capabilities, but it has been a long time since
I used it, so I will not try to explain the procedure.)

In addition:
tclkit for Windows comes in at least two flavours: one tclsh-style and
one wish-style. The tclsh-style is appropriate if you do not need any
interaction with the human user.

Regards,

Arjen

milosl...@gmail.com

unread,
Jun 19, 2013, 9:29:17 AM6/19/13
to
> In addition:
>
> tclkit for Windows comes in at least two flavours: one tclsh-style and
>
> one wish-style. The tclsh-style is appropriate if you do not need any
>
> interaction with the human user.

Not really, IMO.

Tclsh is - we are talking Windows - only appropriate when what you want is a console application.

Wish is more appropriate if you don't want user interaction _AND_ don't want useless shell/cmd window occupying the screen. Some users get unnerved by a strange black window, others will close it without thinking - and then complain that the app didn't work or did only part of the work ;-)))

Arjen Markus

unread,
Jun 19, 2013, 9:48:08 AM6/19/13
to
Op woensdag 19 juni 2013 15:29:17 UTC+2 schreef milosl...@gmail.com het volgende:

>
> Tclsh is - we are talking Windows - only appropriate when what you want is a console application.
>
>
>
> Wish is more appropriate if you don't want user interaction _AND_ don't want useless shell/cmd window occupying the screen. Some users get unnerved by a strange black window, others will close it without thinking - and then complain that the app didn't work or did only part of the work ;-)))

Hm, I was thinking of applications that start a program and take care of
hiding the DOS-box (or perhaps: neglecting to create it). But you are right,
there are all sorts of scenarios possible and imaginable - sigh.

Regards,

Arjen

Kevin Walzer

unread,
Jun 19, 2013, 10:20:30 AM6/19/13
to
On 6/19/13 3:47 AM, Arjen Markus wrote:
> tclkit sdx.kit wrap <project>.exe -runtime tclkit-copy.exe

Using sdx is the simplest way to create the standalone executable, but
it does not obfuscate your code in any way. A savvy user just has to run

sdx unwrap <project>

and it will dump all the files into a readable format. I have tried this
with one or two commercial Tcl/Tk apps and was rather surprised to see
that I could read the source code.

Most users won't take the time to do this, but it's just something to be
aware of.

TDK will obfuscate your code as well as wrapping it into a standalone
executable that is sourced via tbcload; the drawback to this approach is
that it makes customer support more complicated, in that if errors
occur, the stack traces will be replaced by a message that refers to
"compiled code" and do not refer to the place in your code where the
error was generated. I found this sufficiently annoying that I stopped
compiling my code.

--Kevin

--
Kevin Walzer
Code by Kevin/Mobile Code by Kevin
http://www.codebykevin.com
http://www.wtmobilesoftware.com

Hans

unread,
Jun 19, 2013, 2:45:21 PM6/19/13
to
Thanks for so many responses.
Summary of all these ideas, 4 ways can do this:tcltdk, tclpro, tclkit, starkit

tcltdk is commercial version. looks like the best way, but we have to pay.
tclpro, commercial version too? I download one but cannot compile successfully on my ubuntu.
tclkit & starkit, I wonder if these two are actually one same stuff? Even tclkit was supposed to be able to do wrapping, but as Kevin said: "it does not obfuscate your code in any way".

George Petasis

unread,
Jun 19, 2013, 3:37:05 PM6/19/13
to
Στις 19/6/2013 9:45 μμ, ο/η Hans έγραψε:
> Thanks for so many responses.
> Summary of all these ideas, 4 ways can do this:tcltdk, tclpro, tclkit, starkit
>
> tcltdk is commercial version. looks like the best way, but we have to pay.
> tclpro, commercial version too? I download one but cannot compile successfully on my ubuntu.

tclpro was a commercial tool, 10-15 years ago. It was released as open
source by the company when it went out of business, and ActiveTcl used
it as a starting point for their (also commercial) TDK related tools.

So, in a way tclpro has been evolved into ActiveState's TDK. The
original tclpro was left almost unmodified, which means it cannot
support more recent tcl versions. Perhaps this is the reason it does not
compile any more.

George

Eckhard Lehmann

unread,
Jun 19, 2013, 3:26:46 PM6/19/13
to
Am 19.06.13 20:45, schrieb Hans:

> tclkit & starkit, I wonder if these two are actually one same stuff?

Yes they are.
For tclkit you need to deploy two files, the tclkit itself and your .kit
application. Or just your .kit application if you can expect your users
to have a tclkit installed and know how to use it - which is usually not
the case.
A starkit contains everything, your .kit application and the tclkit. In
almost all cases this is probably the right way to get your app on the
users desktop (and usually it will land just there ;)).

> but as Kevin said: "it does not obfuscate your code in any way".

As far as I know, you can byte-compile your scripts by yourself. I've
done that in the past, but I don't remember how.

--
Eckhard

Arjen Markus

unread,
Jun 20, 2013, 3:00:19 AM6/20/13
to
Op woensdag 19 juni 2013 21:26:46 UTC+2 schreef Eckhard Lehmann het volgende:

>
> > but as Kevin said: "it does not obfuscate your code in any way".
>

An alternative is to encrypt/obfuscate the code. LRI has a tool for that:
http://www.lr-i.com/LRIOBF.html (or on the Wiki: http://wiki.tcl.tk/26466)

It was presented at the EuroTcl users meeting a couple of years ago.

Regards,

Arjen

mse...@gmail.com

unread,
Jun 20, 2013, 4:34:41 AM6/20/13
to
If I remember rightly the encryption is one way so if you loose your code even LRI cannot get it back

MArtyn

paskali

unread,
Jun 20, 2013, 1:05:50 PM6/20/13
to
Hi, i suggest you to consider the old version of freewrap, the 4.4, it
makes very small and very fast standalone binaries (from 250kb for pure
tcl, 750kb with tk) and the source codes are hidden by default.
It is easy to make big projects, too.
Of course you are to consider the old version of tcl/tk (the 8.3), but i
have found always some sort of way to replace the newer usefull features.

I have also used starkit but freewrap 4.4 makes programs more small and
more fast.

I hope that is usefull.

Regards

Pasquale

--
Pasquale Frega
Tiny C compiler and Freewrap user
I have a Commodore 64, too
http://www.webuse.net/pm.php?u=2970

Posted using www.webuse.net

Hans

unread,
Jun 20, 2013, 7:23:50 PM6/20/13
to
On Thursday, June 20, 2013 10:05:50 AM UTC-7, paskali wrote:
> Hi, i suggest you to consider the old version of freewrap, the 4.4, it
>
> makes very small and very fast standalone binaries (from 250kb for pure
>
> tcl, 750kb with tk) and the source codes are hidden by default.
>
> It is easy to make big projects, too.
>
I tried freewrap but failed, my project need to use Expect, TK, and local file access, plus some newer tcl packages. looks like pure tcl is ok for freewrap, but hard to work with many other extensions. (I could be wrong because I'm really not a good linux programmer)

tcltk-d

unread,
Jun 26, 2013, 11:24:52 PM6/26/13
to
tkwrap(freewrap) can considerably and freely include libraryies(.tcl,.dll),
so,please select and wrap libaries you need,
then load,or source them at start.

see Example:

at http://members.jcom.home.ne.jp/tcltk-d/
which is built by:
/tcl/tkwraps/tkwrap TclTkD.tcl -o TclTkD.exe /wrap/optcl.dll /wrap/tkimg13.dll
... /wrap/xphoto.dll /wrap/ffidl.dll /wrap/TkdPrefs.tcl


0 new messages