tclapp or tclcompiler

Posted by andilee on 2014-04-02 01:08
Forums: TDK discussion | OS: Other Linux

Hay guys,
I am a little bit confuse about tclapp and tclcompiler. Actually, my objection is simple: to warp a tcl to become an platform-independent executable file.

1. I have reviewed tcl_compiler_reference and seems like it's the one I need. And what's the difference between tclapp and tclcompiler?

2. When I execute tclcompiler input.tcl, I can get the .tbc file and it can be executed on tclsh. However when I run it on PrimeTime, I got Error

From reference I know that I need to download a newer version of tbcload from tbcload_download. But I have no idea where to put this file and how to use it.

3. This folder will contain folder_data and both 84 and 85 folders contains libtbcload1.6.so, so which one to use?

4. Do I need to set anything by using this setting inside pkgIndex.tcl? pkgIndex.tcl

Thank you in advance,
Andi

grahams
ActiveState Staff
Wed, 2014-04-02 10:21

You can wrap Tcl script into an "executable" file, but you must do a different wrap for every platform you want to run on.

You can get platform independence in your file, but that file cannot behave like an executable.

TclApp is a wrapping tool. It creates a single file package that can be stand-alone if a Tcl interpreter is included, so it acts like an executable. Tcl scripts are packaged inside the wrapped file. They can be normal Tcl script, or Tcl converted to bytecode with TclCompiler.

TclCompiler is not a true compiler. The main use-case for TclCompiler is source code obfuscation. It converts Tcl script into intermediate bytecode, which can be injected into a properly prepared Tcl interpreter (must be same major revision of Tcl or newer, and must have tbcload injector module installed). Since bytecode is really just script, bytecode can be used on other platforms if there is a native Tcl interpreter prepared for it.

You have linked to TEApot. That's a prebuilt binary version for use with ActiveTcl 8.4. An ActiveTcl 8.4, 8.5, or 8.6 will not need this, as it will already have a matched (and newer) version of tbcload pre-installed. It's in the repository to support TclApp wrapping for foreign operating systems.

It looks like PrimeTime has it's own Tclsh. You should not use the TEApot version of tbcload with a different Tcl distro. To add tbcload to a non-ActiveTcl, the module should be compiled locally from source code that is shipped with the Tcl Dev Kit. You will need to be familiar with the basic methods for building modules from source.

andilee | Wed, 2014-04-02 22:40

Hay Graham, Thank you again!
Actually after more thinking, I think I need to re-frame my objection : to create a source code obfuscation file which can be run on PrimeTime.

So from your explanation, I can made a summary just as below and I will also make some reply with bold letter (please correct me if I am wrong) :

1. We have to warp different package according to the machine you want the package to be run on.

2. TclApp is a wrapping tool which can acts as executable file IF Tcl interpreter is included.

3. TclCompiler is a tool that generate intermediate bytecode whose main objective it to create a source code obfuscation.
(So this is the one I need)

4. We can also wrap a .tbc (TclCompiler output file) file as an executable file by using TclCompiler + TclApp

5. PrimeTime has its own Tclsh, so I cannot use the TEApot version of tbcload.
So what can I do to solve this problem? I might need some guidance on this, please help me :)

Quote from your reply:
"You have linked to TEApot. That's a prebuilt binary version for use with ActiveTcl 8.4. An ActiveTcl 8.4, 8.5, or 8.6 will not need this, as it will already have a matched (and newer) version of tbcload pre-installed. It's in the repository to support TclApp wrapping for foreign operating systems."
I installed the ActiveTcl8.6.1.0, so from your explanation, it should have the newer version pre-installed automatically?

Thank you in advance,
Andi

andilee | Sun, 2014-04-06 18:36

Anyone have the experience on this?