This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Tcl/Tk with extensions under cyg-win32?


> I was hoping somebody has had some experience with what I want to do. I'd
> like to compile Tk/Tcl 4.2/7.6 with several extensions, including itcl 2.2,
> TclX, Expect, and Scotty (Tnm). I'd like to compile them as shared
> libraries/loadable packages, if that is possible under cyg-win32. If not, I
> suppose I can just link them in statically, it's just that I'd rather not.
> 
> I was wondering if anyone had any experience in doing this and, if so, what
> problems were run into. How much had to be changed to compile under
> cyg-win32? What target opsys did you use, linux? What other things should I
> be concerned about when I go about doing this.

With tcl's dynamic package-concept you don't have to rebuild tcl/tk at
all but use the provided b18-tcl/tk-binaries instead. Just make dlls from the
extensions and use the package-mechanism to load them dynamically,
that's all. I did that for itcl1.5 and my own extensions.

If the generation of relocatable dlls won't work for you (perhaps due
to some weird c++-code in your extensions) make static-packages
('.a'-archives) and use the tcl-package-mechanism for static
packages. Then you won't have to recompile tcl/tk either but only
extend the interpreter. Assume you have an gnuwin32-compiled archive 'itcl-2.2.a' you
want to use as a static package in tcl. Then build your own
interpreter that has the package included:


: #include <tcl.h>
: 
: static int 
: loadStaticPackages( Tcl_Interp* interp ) {
:   char loadCmd[256];
: 
:   Tcl_StaticPackage( NULL, "itcl"   ,   Itcl_Init,    NULL );
:   strcpy( loadCmd, "load \"\" itcl" );
:   Tcl_Eval( interp, loadCmd );
: }
: 
: 
: int
: Tcl_AppInit(Tcl_Interp* interp) {
:   if (Tcl_Init(interp) == TCL_ERROR) {
:     return TCL_ERROR;
:   }
:   return ( loadStaticPackages( interp ) );
: }
: 
: int
: main(int argc, char** argv) {
:   Tcl_Main(argc, argv, Tcl_AppInit);
:   return 0;       
: }
 
Now you can use "package require Itcl" in your tcl-code in the same
manner as if you wanted to load the package dynamically. So if you
succeed to build dll's from your extensions in the future (perhaps
with oncoming b19) you wont't have to change your tcl-code.

Hth,

--- Roland.

---
Roland Geier                    Phone: ++49 (8505) 92182          
Universitaet Passau, GER 	Fax:   ++49 (8505) 922311
Lehrstuhl Prof. Dr. Donner      geier@forwiss.uni-passau.de	
D-94032 Passau                  http://www.uni-passau.de/~geier/











-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]