From: Ian Petts on
I've just started getting into TCL and am in the process of writing my
first application, which is a simple database using the sqlite libraries.

I've been developing the program under Linux, but would like to make it
available under Windows as well and would prefer to have a
self-contained executable rather than require the user to install the
full TCL suite and sqlite libraries.

Thus, I've been looking at the freewrap program to generate a Windows
executable. I have a windows box (without TCL installed) and have been
attempting to build the executable on this machine.

I've been reading and re-reading the docs on the freewrap
site, but am having difficulty understanding exactly what I need to do
to make this work.

I downloaded and unzipped the sqlite TCL bindings dll into the same
directory as myprog.tcl. I have tried both the "1) freeWrap as a TCL/TK
wrapper program" and "7) Wrapping and using TCL/TK extensions
(packages)" sections of the howto without success.

Freewrap does not generate an error, and the resulting executable runs,
but I keep getting an error 'invalid command name "sqlite3"' when the
program gets to the sqlite portion of the code.

The line 'package require sqlite' seems to be all that is required to
make the program work on my linux box. I've tried this, plus 'load' and
'open', but am really quite in the dark about what I _should_ be doing,
as opposed to how I should be doing it.

It appears I am either not wrapping the dll properly, or I am using the
wrong TCL commands to load the dll in windows.

Could someone please give me a specific example of a small TCL program
that uses the sqlite dll, and how to successfully wrap it?

Any help greatly appreciated.

From: Aric Bills on
I don't have much experience with Freewrap, but I can help you get up
and running with a starpack if you're willing to go that route. (A
starpack is an executable Tcl program built using Jean-Claude Wippler's
Tclkit software.) The basic process goes like this:

Set up tclkit (steps 1-3)
Set up sqlite as a tclkit-friendly package (steps 4-5)
Set up and build your app (steps 6-9)

Here's what to do:

1) download the appropriate Tclkit executable from
http://www.equi4.com/tclkit.html. You will probably want one of the
following four files:

Tcl 8.4.9, with Tk:

http://www.equi4.com/pub/tk/8.4.9/tclkit-win32.upx.exe

Tcl 8.4.9, without Tk:

http://www.equi4.com/pub/tk/8.4.9/tclkitsh-win32.upx.exe

Tcl 8.5a2, with Tk:

http://www.equi4.com/pub/tk/8.5a2/tclkit-win32.upx.exe

Tcl 8.5a2, without Tk:

http://www.equi4.com/pub/tk/8.5a2/tclkitsh-win32.upx.exe

2) make a copy of the program you downloaded in step 1--call it
tclkitcopy.exe or something.

3) download sdx.kit from http://www.equi4.com/pub/sk/sdx.kit and put it
in the same directory as the files from steps 1 and 2. (See
http://www.equi4.com/sdx.html for info on SDX.)

4) put your sqlite DLL in a directory by itself (NOT the same directory
as in steps 1-3).

5) in the same directory as the sqlite DLL, create a file called
pkgIndex.tcl. Put the following code into the file:


package ifneeded sqlite 3.2 \
[list load [file join $dir tclsqlite3.dll]]


(if you're not using version 3.2 or your dll isn't called
tclsqlite3.dll, change the above code as appropriate)

6) in the same directory as the files from steps 1-3, create a file
called test_sqlite.tcl, containing the following code (which comes from
http://wiki.tcl.tk/2633, with thanks to JimG):


package require sqlite

sqlite3 db myfirstdb.whateverILikeOrNothing
db eval {Create Table myFirstTable(name, language)}
db eval {Insert Into myFirstTable Values('JimG', 'Chinese')}
db eval {Insert Into myFirstTable Values('BillG', 'English')}
db eval {Select * From myFirstTable}
db close


7) run the executable you downloaded in step 1. You'll get a tcl shell
or a wish console, depending on whether you downloaded a tclkit with Tk
or not. Type the following into the shell/console:

source sdx.kit
package require sdx
sdx::sdx qwrap test_sqlite.tcl
sdx::sdx unwrap test_sqlite.kit


Leave the shell/console open.

In the directory where the files from steps 1-3 are, you've just created
the subdirectory test_sqlite.vfs.

8) Now take the directory you created in step 4 and copy it and its
contents as a new subdirectory of test_sqlite.vfs\lib\. Once you do
this there will be two subdirectories of test_sqlite.vfs\lib\: the
sqlite directory you just copied, and the directory app-test_sqlite,
which contains your Tcl script, slightly doctored by tclkit. Any
further changes to your program should be made to the script in the
app-test_sqlite directory.

9) In the tclkit shell/console, type:

sdx::sdx wrap test_sqlite.exe -runtime <tclkitcopy.exe>

where <tclkitcopy> is the name of the executable from step 2.


That's it. You should have a useless but operational executable,
test_sqlite.exe, that successfully wraps and uses sqlite. To modify
this program, edit the script in test_sqlite.vfs\lib\app-test_sqlite\,
then repeat step 9.
From: Ian Petts on
On 2005-07-23, Aric Bills <aric.b(a)u.washington.edu> wrote:

> I don't have much experience with Freewrap, but I can help you get up
> and running with a starpack if you're willing to go that route.

Not at all. I was so wrapped up (yes, bad pun) trying to get freewrap
working that I hadn't looked at the other options too well.

> Set up tclkit (steps 1-3)
> Set up sqlite as a tclkit-friendly package (steps 4-5)
> Set up and build your app (steps 6-9)

Wow! That works *perfectly*, in your example _and_ with my app.

Thank you very much, Aric!

Regards,
Ian.
From: Dennis LaBelle on
Ian Petts wrote:

> I've just started getting into TCL and am in the process of writing my
> first application, which is a simple database using the sqlite libraries.
>
> I've been developing the program under Linux, but would like to make it
> available under Windows as well and would prefer to have a
> self-contained executable rather than require the user to install the
> full TCL suite and sqlite libraries.
>
> Thus, I've been looking at the freewrap program to generate a Windows
> executable. I have a windows box (without TCL installed) and have been
> attempting to build the executable on this machine.
>
> I've been reading and re-reading the docs on the freewrap
> site, but am having difficulty understanding exactly what I need to do
> to make this work.
>
> I downloaded and unzipped the sqlite TCL bindings dll into the same
> directory as myprog.tcl. I have tried both the "1) freeWrap as a TCL/TK
> wrapper program" and "7) Wrapping and using TCL/TK extensions
> (packages)" sections of the howto without success.
>
> Freewrap does not generate an error, and the resulting executable runs,
> but I keep getting an error 'invalid command name "sqlite3"' when the
> program gets to the sqlite portion of the code.
>
> The line 'package require sqlite' seems to be all that is required to
> make the program work on my linux box. I've tried this, plus 'load' and
> 'open', but am really quite in the dark about what I _should_ be doing,
> as opposed to how I should be doing it.
>
> It appears I am either not wrapping the dll properly, or I am using the
> wrong TCL commands to load the dll in windows.
>
> Could someone please give me a specific example of a small TCL program
> that uses the sqlite dll, and how to successfully wrap it?
>
> Any help greatly appreciated.

You should take a look at

http://freewrap.sourceforge.net/freewrap_howto.html#7

Especially the part about "Extensions containing binary files".

Wrapping and using TCLSQLITE is fairly straight-forward if you use the
sample code for the freewrap_load procedure provided at the above Web
address. Include this PROC in you application source code then add the
following line to load the SQLITE extension:

freewrap_load tclsqlite3.dll

You also need to include the DLL as one of the files you wrap into your
final application. For example, your wrapping command line might look like

freewrap yourApp.tcl tclsqlite3.dll

Remember, the freewrap_load command only works once the application is
wrapped. Otherwise, if you are using freeWrap as a stand-alone WISH, simply
load the DLL with the following command (you may need to use the full path
to the DLL file).

load tclsqlite3.dll

Dennis LaBelle

From: Ian Petts on
On 2005-07-23, Dennis LaBelle <labelled(a)nycap.rr.com> wrote:
> freewrap_load tclsqlite3.dll
> freewrap yourApp.tcl tclsqlite3.dll

Ah, that's got it. It all looks so simple now.

I had tried freewrap_load, but somehow I managed to over-complicate the
whole process and ended up confusing myself.

Thanks very much, Dennis!

Regards,
Ian.