to date i've not successfully wrapped tcl/tk program that needed a
binary extension...
i followed the freewrap docs but i still get a 'can't find package
xml' error
i've resisted asking before because i kept asking myself 'how hard
could it be?'
now i just want the anwer :)
http://home.cogeco.ca/~tsummerfelt1
telnet://ventedspleen.dyndns.org
Just what "XML extension" are you talking about. Where can you download it
from. I can help, but I need this info first.
Dennis LaBelle
So you wrap the binary file. Then you try to [::freewrap::unpack] it to
a location that will be searched by the [package require] mechanism?
Does the file get there?
More info about what you are doing will help others tell what you are
doing wrong.
Gerry
>Just what "XML extension" are you talking about. Where can you download it
>from. I can help, but I need this info first.
looking at the activestate lib directory the extension directory
is: tclxml2.6 which includes a tclxml26.dll file among other *.tcl
files.
http://home.cogeco.ca/~tsummerfelt1
telnet://ventedspleen.dyndns.org
>So you wrap the binary file. Then you try to [::freewrap::unpack] it to
>a location that will be searched by the [package require] mechanism?
>Does the file get there?
i used both methods described in the freewrap documentation for binary
extensions (for extension that are stub enabled, and those that
aren't.)
http://home.cogeco.ca/~tsummerfelt1
telnet://ventedspleen.dyndns.org
> http://home.cogeco.ca/~tsummerfelt1
> telnet://ventedspleen.dyndns.org
>Please show us the wrapping and
>the unwrapping code. Your goal should
>be easily reachable.
i created a list of files in the tclxml2.26 directory (full paths)
i used: load tclxml26.dll in the program.
i wrapped with freewrap tclxml26.dll -f tclxml.lst
then i tried the same thing with the freewrap_load code that the docs
include.
with both of those attempts i tried to lappend the directory for the
dll, and i tried without.
all told i tried about 6 different combinations of the above.
if there's something else i'm missing, then i still am :)
http://home.cogeco.ca/~tsummerfelt1
telnet://ventedspleen.dyndns.org
Puzzled you didn't use a package require as the
extension has large-ish pkgIndex.tcl file.
>
> i wrapped with freewrap tclxml26.dll -f tclxml.lst
>
> then i tried the same thing with the freewrap_load code that the docs
> include.
Sounds Ok. But w/o code there's no way to assist
for possible errors.
>Puzzled you didn't use a package require as the
>extension has large-ish pkgIndex.tcl file.
i did. i followed the documentation.
>Sounds Ok. But w/o code there's no way to assist
>for possible errors.
i'm not sure this will make it easier for you, but here's the code:
lappend auto_path c:/lang/tcl/lib/tclxml2.6
package require xml
load ./tclxml26.dll
and i try to wrap with:
freewrap xmltest.tcl tclxml26.dll-f c:/lang/tcl/lib/tclxml26
and i've used the freewrap_load method also.
http://home.cogeco.ca/~tsummerfelt1
telnet://ventedspleen.dyndns.org
Have you verified that after you
"used the freewrap_load method" that the
full set of files under tclxml2.6 was created
in the directory on drive C of the test machine?
> package require xml
> load ./tclxml26.dll
I've never seen a package that required
a load after a package require. I believe
that is an error in your code. Can you
point to documentation for tclxml that
states otherwise?
The docs I see in the ActiveState
help for tclxml do not show a load.
>
>
> and i try to wrap with:
>
> freewrap xmltest.tcl tclxml26.dll-f c:/lang/tcl/lib/tclxml26
This looks wrong. The freewrap "-f" option takes a
file containing a list of files. You appear to be
supplying a directory name. In order for this
to work you need to collect the file names into
a text file and supply the text file name to
the -f option.
This should be pretty easy as all the files
of tclxml appear to be in the same directory.
>
> and i've used the freewrap_load method also.
The freewrap_load proc included in the freewrap
doc file is not sufficient for tclxml as it has
multiple files. I suggest taking freewrap_load
as instructive example. But to get the library
you want loaded you should plan to explicitly unload
every file to the local disk using a loop and
a call to ::freewrap::unpack for every
file.
If all this dicussion is seeming too opaque then
finding some wrapper that already includes the
package may be the right path for you.
>
>
>
> http://home.cogeco.ca/~tsummerfelt1
> telnet://ventedspleen.dyndns.org
>Have you verified that after you
>"used the freewrap_load method"
i'm not sure what you mean by 'verified'
i followed the freewrap documentation which lists the code to insert
into the application that uses a the binary extension.
following that i use the freewrap_load command as per the freewrap
documatation
but i HAVE tried with just "package require xml" .
i believe it's my lack of understanding what freewrap needs to wrap
the xml extension
rather than going around in circles, i'd ask if anyone had
successfully wrapped a script with the xml extension and what they did
to get it wrapped.
http://home.cogeco.ca/~tsummerfelt1
telnet://ventedspleen.dyndns.org
OK, here is the answer.
BACKGROUND
----------
The freewrap_load procedure provided in the freeWrap documentation can be
used but it is only part of the picture. When wrapping a simple binary
extension that has no TCL support scripts associated with it you can use
freewrap_load to directly load your DLL. However, we do NOT have such a
situation with Tclxml.
The Tclxml extension has several supporting scripts whose loading is
normally automated by the [package require] command. We need to use the
[package require] command but the associated pkgIndex.tcl file doesn't
really know how to load our DLL. This is easy to correct by making a slight
modification to Tclxml's pkgIndex.tcl file so that it uses the
freewrap_load command instead of the regular load command.
In our situation, there is one more thing to worry about. The Tclxml.dll has
some dependencies (i.e., calls other DLLs). Therefore, we need to:
1) wrap these other DLLs into our program
2) unpack these other DLLs to the local file system before loading the
Tclxml DLL
Again, this is easy to accomplish by making a simple change to the Tclxml
pkgIndex.tcl file that we wrap into our application.
The procedure I used to wrap an application containing and using Tclxml
version 3.1 follows.
PROCEDURE
---------
1) Modify the Tclxml pkgIndex.tcl file as follows:
Replace the following line in the pkgIndex.tcl file
package ifneeded xml::c 3.1 [list load [file join $dir Tclxml31.dll]]
with (the following is a single line. It may suffer from wrap around)
package ifneeded xml::c 3.1 [foreach fpath [zvfs::list *.dll]
{freewrap::unpack $fpath}; freewrap_load [zvfs::list */Tclxml31.dll]]
This modification will unpack all DLLs from the wrapped binary, then load
the Tclxml DLL itself.
2) Add some code to your application to adjust the auto_path variable. You
should ensure that all wrapped directories containing pkgIndex.tcl files
are added to auto_path. For my project, I added the following code at the
beginning of my application. It should be executed before the [package
require] command.
foreach fpath [zvfs::list */win/*/pkgIndex.tcl] {
lappend auto_path [file dirname $fpath]
}
As you can see, with this code the location of the files is determined at
run time. I didn't have to keep track of them to properly update the code.
The [zvgs::list] command is very useful for locating your wrapped files.
3) Use a [package require xml] commnad in your application to load the
Tclxml package.
4) FreeWrap your application. Make sure you include all the supporting DLLs
and script files.
5) Have fun!
Dennis LaBelle (The freeWrap Guy)
This last part is probably more than you really need to do.
Please see the response I provided to this thread earlier today for
instructions on how to properly wrap the Tclxml extension.