5. How do I build it?

In general, building perl/Tk requires:

  1. 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.
  2. A C language compiler for the Tk code itself.
  3. 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:
  1. make install # the appropriate version of perl.
  2. uninstall # prior versions of the Tk extension to perl.
  3. gunzip -c Tk-b*.tar.gz | tar xvf -
  4. cd Tk-b*
  5. read INSTALL
  6. perl Makefile.PL
  7. make
  8. make test
  9. 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:

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:

Platforms:

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.

non-Unix(ish)es:

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