delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1997/11/24/08:42:26

From: yas AT oberon DOT csse DOT swin DOT edu DOT au (Y. Ahmet Sekercioglu)
Subject: (Updated) Sample code for beginners of tcl/tk & cygwin32 environment
24 Nov 1997 08:42:26 -0800 :
Message-ID: <Pine.LNX.3.95.971124095234.13827D-100000.cygnus.gnu-win32@oberon.csse.swin.edu.au>
Mime-Version: 1.0
To: gnu-win32 AT cygnus DOT com

#include <stdio.h>
#include <tcl.h>
#include <tk.h>

/* 
   compilation & linking on Linux:
   gcc -o tkhelloworld tkhelloworld.c -L/usr/X11R6/lib \
                                                 -ltcl -ltk -lX11 -ldl -lm 

   compilation & linking on WinNT (cygwin32 version b18):
   gcc -o tkhelloworld tkhelloworld.c -ltcl7.6 -ltk4.2

   if you do not want a console window appearing everytime you
   run the program, here are the compilation & linking options
   for WinNT (cygwin32 version b18):
   gcc -o tkhelloworld tkhelloworld.c -ltcl7.6 -ltk4.2 \
                                           -luser32 -Wl,--subsystem,windows
   (Thanks to Jason L. Esman)					 
*/

int main(argc, argv)
     int argc;
     char **argv;
{
  Tk_Window mainWindow;
  Tcl_Interp *tcl_interp;
  
  tcl_interp = Tcl_CreateInterp();

  if(Tcl_Init(tcl_interp) != TCL_OK || Tk_Init(tcl_interp) != TCL_OK) {
    if(*tcl_interp->result)
      (void)fprintf(stderr,"%s: %s\n", argv[0], tcl_interp->result);
    exit(1);
  }

  mainWindow = Tk_MainWindow(tcl_interp);
  if (mainWindow == NULL) {
    fprintf(stderr, "%s\n", tcl_interp->result);
    exit(1);
  }
  
  Tcl_Eval(tcl_interp, "button .b -text \"Hello World\" -command exit");
  Tcl_Eval(tcl_interp, "pack .b");

  Tk_MainLoop();

  exit(1);
}


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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019