5. How do I build it?
In general, building perl/Tk requires:
	
	- A made & installed perl (requires a C language compiler). You 
	may need different versions of perl depending on which version of Tk 
	you wish to run.
- A C language compiler for the Tk code itself.
- A linkable Xlib (.o, .so, .a, etc.) for X-windows.
Perl/Tk has been successfully built using various vendors'cc
compilers, as well as with the free GNU gcc compiler. A
make utility of some sort (make/gmake)
will be extremely helpful.
The versions of the various Perl utilities that you need on hand are 
roughly as follows:
  Utility     Version              Tk version/comments
  perl        5.001m               Tk-b8 (not 5.001n)
  perl        5.002b1f (or higher) Tk-b9 (9.01 recommended)
  perl        5.002b1f (or higher) Tk-b9.01
  perl        5.002                Tk-b10
  perl        5.002                Tk-b11
  perl        5.002                Tk-b11.01
  perl        5.002 (or 002_01)    Tk-b11.02
  MakeMaker   4.18 (or higher)     Tk-b8
  MakeMaker   5.14 (or higher)     Tk-b9.01 
  MakeMaker   5.21 (not? higher)   Tk-b11+
  xsubpp
Step - by - step the commands to build the Tk extension to Perl are (for the 
dynamically linked version) roughly as follows: 
	
	-  make install # the appropriate version of perl.
	
-  uninstall # prior versions of the Tk extension to perl.
	
-  gunzip -c Tk-b*.tar.gz | tar xvf -
	
-  cd Tk-b*
	
-  read INSTALL
	
-  perl Makefile.PL
	
-  make
	
-  make test
	
-  make install
	
For the statically linked version you would `make tkperl` just after
executing the `make` step and before the `make test` step.
A relatively easy way to determine if the perl on your system allows for
dynamic linking was mentioned by  Kenneth Albanowski <kjahds@kjahds.com>.
If the following does not say "dl_none.xs" then you probably do not
have dynamically linked perl (or perhaps a very non-Unix perl):
    perl -e 'use Config; print $Config{dlsrc},"\n"'
Here is a little more detailed discussion of each the steps just given:
	
	-  Install Perl (5.001m for Tk-b8 [not 5.001n], at least 
                5.002b1f for b9.01, 5.002 for b11.01, 5.002 for b11.02)
		For code locations 
		see a CPAN site (separate question in this FAQ), 
		the actual installation instructions come bundled in the 
		perl***.tar.gz distribution file. 
		(Perl Configure & make troubles are beyond the scope of 
		this FAQ - please see the 
		Perl FAQ 
		itself for more help with this critical step.)
 You can install perl almost anywhere you like by specifying the
		-Dprefix=/path argument to 
		sh Configure
-  Unpack perl/Tk outside the Perl distribution
 (i.e. outside the perl build, perl install, or perl lib
		areas).
 gunzip Tk-b*.tar.gz
 tar -xvf Tk-b*.tar
 (this area Tk-b*/ will be referred to as your 
		``Tk build'' directory)
 (optional: with Tk-b9.01, to avert most 
		pod2man errors later on you may wish to apply 
		Nick's document patch.)
-  Read INSTALL carefully
 cd Tk-b*
 pager INSTALL
 where pager is the program you use to scroll
		through text files more or less. Be sure to read it and don't
		just pound away on the spacebar.
-  If necessary remove any previously installed version of perl/Tk
 If you had a previously working version of Tk installed, you 
		may need to resurrect the Makefile for it and execute:
 make uninstall
 make realclean
 before you unpack the new version. (The uninstall target of 
		MakeMaker is relatively new so please be careful here.)
 Also note that as of Tk-b10 there is now anuninstallperl script in the Tk build directory. 
		Run that script before the perl Makefile.PL step if
		you had a previously installed Tk extension (especially if the
		version number was prior to b10, e.g. Tk-b9.01 or Tk-b8).
-  Compile and test.
 perl Makefile.PL
 (see below for more on this step.)
 make
 (if and only if building static: make tkperl
 make test (Tk-b10++ not prior versions)
 
-  Install.
 make install
-  Play with it.
 basic_demo (modify #! line if nec., or
		specify /path/to/perl ./basic_demo)
 warning if you build Tk-b9.01 with perl5.002gamma then
		change the line in basic_demo from
 use lib ./blib;
 to
 use lib qw(blib/arch blib/lib);
On the perl Makefile.PL step it may be necessary to give explicit
locations of the required X11 libraries and/or include headers. For example:
    perl Makefile.PL X11=/usr/local/X11R5
or
    perl Makefile.PL X11INC=/usr/local/share/X11R5/include \
                     X11LIB=/usr/local/arch/X11R5/lib
There are system and site dependencies in all of the above steps. 
However, the largest single source of build trouble comes from not using the
latest versions of the various utilities (C compiler, 
make, etc.). In particular ensure that when you say 
perl Makefile.PL that the perl that gets invoked is up to
date - use which perl and perl -v to determine this. If 
necessary specify the full path name to your perl5 interpreter/compiler. 
(Some people do not rm their older perl interpreters 
 when upgrading to a more recent version - beware.)
If you still run into trouble take a look at the 
INSTALL, the  
README 
and the README file for your specific system
(e.g. README.AIX, README.OSF, etc.).
You might also find your system mentioned in the ptk hyper-mail archive at:
    http://pubweb.bnl.gov/~ptk/
or
    http://www.rosat.mpe-garching.mpg.de/mailing-lists/ptk/
or
    ftp://ftp.ccd.bnl.gov/pub/ptk/archives/
or the Perl 5 Porters page at one of the following URLs:
    http://www.rosat.mpe-garching.mpg.de/mailing-lists/Perl5-Porters/
    http://www.hut.fi/~jhi/perl5-porters.html
    http://www.nicoh.com/cgi-bin/lwgate/PERL5-PORTERS/
If you wish to discuss your Tk build problems with others run and save the
output from the myConfig script in the Tk build directory
(the output may already be in the myConfig.out file from your 
Tk-b# build directory), as well as the myconfig script in your 
perl build directory. It is often helpful to include the output of either 
(or both) of these scripts in your discussion.
Presented here are the beginnings of a list of problems associated with
building Tk-b# on various platforms (for help building perl itself please 
refer to the Perl FAQ). This list 
is in no way complete nor authoritative (nor is it necessarily even 
up-to-date!) but simply lists problems people have reported. Keep in mind that 
your installation may differ (e.g. location differences such as 
/usr/bin/perl vs. /usr/local/bin/perl) even if 
its the same platform listed here:
- AIX:
- 
 As of perl5.002b & Tk-b9.01 README.AIX says no patching is
 necessary. 
 
 For Tk-b8: modifying the perl.exp file may be necessary. There is 
 a patch in Tk-b8/README.AIX. It may be necessary to 
 make regen_headers after the patch.
 
- HPUX:
- 
 For Tk-b11: One person reports a need to add #define TIMEOFDAY_TZ
 to the tkConfig.h header file in order to compile on HPUX 9.05.
 
 Previous versions: Most people seem to prefer the dynamic linking afforded by 
 a recent version of the gcc compiler on this system.
 
- Linux:
- 
 John C. Wingenbach indicates that should you encounter an error message
 like Cannot find -lX11 anywhere at ./myConfig line 184 when running
 your perl Makefile.PL (under Slakware 3.0) that you should be
 more specific about -l/path/to/libX11.a.
 Adam Wasserman <awasser@hermes.sgc.com> has graciously provided a 
 compilation of Linux compilation trials & tribulations. It is an (as yet
 un-edited) document available at:
 
 http://w4.lns.cornell.edu/~pvhp/ptk/etc/linux_compile_compilation.txt
- MachTen:
- 
 Mark Pease <pease@act.sps.mot.com>
 mentions that:
 I was able to get Tk-b11.02 running under MachTen 2.2 perl5.002_01. 
 I did need to make one change to get a round a MachTen problem. In 
 pTk/tclUnix.h, pwd.h is included, but it is also included pTk/tkPort.h 
 (which is included in Lang.h, which is use by tclUnixUtil.c, whew!)
 MachTen's pwd.h can't be included more that once or you get an error.
  
 It looked to me like tclUnix.h was only used in tclUnixUtil.c, so I 
 commented out the #include <pwd.h> in tclUnix.h.
  
- NetBSD:
- 
 Jesus M. Gonzalez <jgb@gsyc.inf.uc3m.es> mentions success with:
 "Tk-b11.01 compiles, installs and runs just out of
 the box in NetBSD-1.1/i386. I just followed the INSTALL
 instructions"
- NeXTSTEP:
- 
 Gerd Knops recently posted a discussion 
 of the steps to get perl running on several NeXTSTEPs  to p5p.
- OSF/1:
- 
 As of perl5.002b & Tk-b9.01 you will probably be able to follow the
 usual instructions. John Stoffel <john@wpi.edu> reports that if you use
 gcc (rather than cc) you should use at least version 2.7.2
 
 For Tk-b8: make is reputedly not up to the task on this system.
 Tk-b8/README.OSF recommends gmake instead.
 Stephane Bortzmeyer 
 <bortzmeyer@pasteur.fr>
 reports a successful build with Perl 5.001m, xsubpp 1.922, 
 MakeMaker 4.23. He points out that it was necessary for him to 
 upgrade the xsubpp and MakeMaker that he received with his copy of 
 Perl5.001m.
 
- SCO:
- 
 For Tk-b8: Eric J. Bohm 
 <bohm@cs.Buffalo.EDU>  
 reported a need to
 comment out line(s) from myConfig and GNUMakefiles using
 GNU make 3.67. (See Tk-b8/README.SCO for specifics.)
- SGI (Irix):
- 
 For Tk-b11.02: Phillip Moore <wpm@morgan.com> reports a clean build on
 IRIX 5.3.
 
 Matthew Black 
 <black@csulb.edu> recently
 mentioned a need to apply "patchSG0000596" to get perl sockets
 to work. His message was copywritten and is not included here. Send 
 e-mail to him 
 to find out where the get "patchSG0000596". 
 
- Suns:
- 
  SunOS (BSD):
 For Tk-b10 on SunOS 4.1.3_U1
 using SparcWorks acc 3.0.1 Frederick L. Wagner <derf@ti.com> reports
  needing to use the perl malloc rather than the system malloc() when building
  perl.
 For Tk-b8: 
  Tom Tignor <tpt2@BBN.COM> reports the 
  following on SunOS (sun4m sparc):
	
	Tue, 28 Nov 1995 13:19:42
 In trying to make, I got a "write: argument mismatch" error
	for the file ptK/Lang.h. I looked at the file and found the offending
	function, Tcl_GetOpenFile, which has a third argument called "doWrite"
	(not "write") in tkGlue.c. I changed the argument from "write" to
	"doWrite" in Lang.h and it's compiling fine (for the moment. :)
 Solaris (System V):
 For Tk-b8: 
  There is trouble getting perl to use Socket routines
  (i.e. trouble with make perl itself not necessarily
  trouble with Tk-b#). See the perl FAQ for more 
  info or the .shar file that 
  Tom Christiansen occasionally 
  posts to comp.lang.perl.misc.
  Further information on perl inter process
  communication can be found in the perlipc* files at:
  
  ftp://ftp.perl.com/perl/info/everything_to_know/.
- SVR4:
- 
 For Tk-b8: 
 Martha G. Armour and Len Reed report on two separate hardware platforms
 running SVR4 - extensive details in Tk-b8/README.SVR4. 
 Interestingly, they report no trouble at all on Linux. 
- Ultrix:
- 
 Peter Prymmer reports that with Tk-b11 it was necessary to change the line in
 Makefile.PL that reads:
 'LIBS'    => ["$xlib -lX11 -lpt -lsocket -lnsl -lm"],
 to read:
 'LIBS'    => ["$xlib -lX11 -lpt -lsocket -lnsl -lm -ldnet"],
 because of a newer X11 in /usr/local that needed the DECnet protocol linking.
 John Stoffel reports a successful build of static Tk-b10 on Ultrix 4.5.
 
Information on non-Unix(ish) perl platforms may be obtained from the 
perl metaFAQ (pmFAQ) at
   http://www.khoros.unm.edu/staff/neilb/perl/metaFAQ/entry-04.html
or the Perl 5 Porters (p5p) page at:
    http://www.rosat.mpe-garching.mpg.de/mailing-lists/Perl5-Porters/
    http://www.hut.fi/~jhi/perl5-porters.html
    http://www.nicoh.com/cgi-bin/lwgate/PERL5-PORTERS/
In general your non-Unix platform must be able to support perl 5 and 
Xlib 
(a C compiler and a make utility are tremendously useful too). 
The long list of UNIX and non-unix
perl 5 ports, Tcl/Tk ports, and Perl/Tk ports that used to
appear here has now moved to a separate web page at:
    http://w4.lns.cornell.edu/~pvhp/ptk/ptkPORT.html
  
	Previous | Return to table of contents | Next