分享
 
 
 

Perl/TkFAQ-6.如何编译安装

王朝perl·作者佚名  2008-05-18
窄屏简体版  字體: |||超大  

原文:

6. How do I build it?

Assuming you are not running a binary distribution then, 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.

[OBSOLETE] 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 Tk400.*.tar.gz | tar xvf - (tar options may vary esp. on SysV)

4. cd Tk400.*

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.

Note carefully that this process leaves behind a large amount of documentation and examples in various sub-directories. You are strongly encouraged to look carefully through your build tree for docs, examples, etc. and keep those valuable files in a safe place. You might consider tar-ing them off and installing in a webserver directory tree.

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 any of the following does not say "dl_none.xs" then you probably do have dynamically linked perl (or perhaps a very non-Unixy perl): perl -V:dlsrcor perl -MConfig -e 'print $Config{dlsrc},"\n"'or perl -e 'use Config; print $Config{dlsrc},"\n"'

(thanks to Paul Lussier <plussier@isd.3com.com> for the correction!).

Here is a little more detailed discussion of each the steps just given:

* Install Perl Read the Tk files (Tk*/README, etc.) for info on which version of perl is required for the perl/Tk kit you obtained.) 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 or the INSTALL file for more help with this critical step.)

You can install perl almost anywhere you like by specifying the -Dprefix=/path argument to sh Configure

* [OBSOLETE] Unpack perl/Tk outside the Perl distribution

(i.e. outside the perl build, perl install, or perl lib areas).

gunzip Tk400.*.tar.gz

tar -xvf Tk400.*.tar

(Your tar program may not take -xvf. The resultant directory area will be referred to as your ``Tk build'' directory throughout this document.)

* [OBSOLETE] Read INSTALL carefully

cd Tk400.*

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.)

* Have perl generate a custom Makefile.

perl Makefile.PL

(see below for more on this step.)

* Compile.

make

(if and only if building static: make tkperl

* Test.

make test

* Install.

make install

* Play with it.

basic_demo

(modify #! line if necessary, 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);)

* Save the documentation and examples in a safe accessible place.

use tar, cp, mv, chmod or whatever you prefer to save the valuable ancillary files from your Tk build tree.

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 perhaps different directory tree specification is necessary with your X installation: 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 (or whence 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://www.rosat.mpe-garching.mpg.de/mailing-lists/ptk/or http://pubweb.bnl.gov/~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

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 perl/Tk build directory), as well as the myconfig script in your perl build directory (or the output of perl -V with a capitol V). 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 perl/Tk 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: A Sampling of Perl/Tk 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. FreeBSD: [OBSOLETE] Nate Patwardhan <nvp@nfic.com> reports no trouble at all with Tk400.200 on FreeBSD-2.1.5 or FreeBSD-2.2.1. 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://www.perltk.org/contrib/hints/linux_compile.txt MachTen: Mark Pease mailto: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 in 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. OS/2: Ilya Zakharevich mailto:ilya@math.ohio-state.edu has compiled a modified form of Tk-b11.02 to work with the Xfree86 client/server package, as well more advanced versions working with the Open32 PM package. 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 mailto: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 mailto: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 mailto:black@csulb.edu recently mentioned a need to apply "patchSG0000596" to get perl sockets to work. His message was copyrighted 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 mailto: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-b8). 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. Windows NT: [OBSOLETE] Nick Ing-Simmons reports success with the alpha Tk404.000 kit, perl5.004, and Visual C++. Gurusamy Sarathy has distributed a binary kit with perl,Tk,etc. precompiled for Windows 32. Support is continuing to allow extension by the Borland C++ compiler as well as cross compiler extendability. non-Unix(ish)es:

Information on non-Unix(ish) perl platforms may be obtained from newsgroups and email lists as well as a few world wide web sites. For example, try the Perl 5 Porters (p5p) [page|archives] at one of: http://www.rosat.mpe-garching.mpg.de/mailing-lists/Perl5-Porters/ http://www.hut.fi/~jhi/perl5-porters.html

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). If you want to run perl/Tk on another computer and simply have the display show up on yours then all you need on your computer is an "X server" The long list of UNIX and non-unix perl 5 ports, Tcl/Tk ports, and Perl/Tk ports that used to appear in this FAQ has now moved to a separate web page at: http://www.perltk.org/contrib/ptkPORT.html

译文:

6. 如何编译安装?

如果你不是用的二进制版本,那么一般说来,编译安装Perl/Tk需要:

1. 已经编译安装好的Perl环境(需要C的编译器)。根据你所选择的Tk的版本,你可能会需要不同版本的Perl环境。

2. C编译器(为了编译Tk本身的代码)。

3. 图形窗口的链接库Xlib(.o,.so,.a等等)。

Perl/Tk已经被用很多不同的cc编译器上成功的安装(包括免费的GNU的gcc编译器)。同时一个make工具会对安装非常有帮助。

编译Perl的Tk模块的一步一步的命令大致如下(动态链接版本):

1. make install (先安装适当版本的Perl)

2. uninstall (卸载原有的旧版本的Tk)

3. gunzip –c Tk400.*.tar.gz | tar xvf - (tar的参数在如SysV等的系统上可能会不同)

4. cd Tk400.*

5. 阅读INSTALL文件

6. perl Makefile.PL

7. make

8. make test

9. make install

对于“静态链接”版本的安装,你应该在执行完make之后而执行make test之前执行“make tkperl”。

请注意,在上面的步骤中我们没有提到大量的相关文档和在那些子目录中的例子。我们强烈推荐你仔细的阅读安装目录里的docs,examples等内容,并且把它们保留在一个安全的地方。你也可以考虑把它们打包安装到一个网络服务器的目录中去。

Kenneth Albanowski提供了一个相对简单的方法用来测试是否你系统上的Perl允许动态链接。如果下面的任何一个命令没有显示“dl_none.xs”,那么你应该已经安装的动态链接的Perl:

perl –V:dlsrc

perl –Mconfig –e ‘print $Config{dlsrc},”\n”’

perl –e ‘use Config; print $Config{dlsrc},”\n”’

(感谢Paul Lussier的更正!)。

下面是关于上面给出的步骤的一些更详细的讨论:

l 安装Perl: 应该先阅读你获取到Perl/Tk包中的说明文件(Tk*/README等等)来了解它所要求的Perl的版本。相应的Perl代码可以从CPAN得到,其实际的安装说明在perl*.tar.gz的包里面。(关于Perl的配置和安装等问题已经超出来我们这个FAQ的范围,详情请参阅Perl FAQ文件)

l 在Perl的安装目录以外解开Perl/Tk的包

gunzip Tk400.*.tar.gz

tar –xvf Tk400.*.tar

(注意:你的tar程序也许会不认-xvf选项。另外,解开以后的目录我们在下面的文档中将称之为“Tk安装目录”。)

l 仔细阅读INSTALL文件

cd Tk400.*

pager INSTALL

注:这里的pager是指你用来阅读整个文本的工具,请务必仔细阅读此文档而不要简单跳过!

l 如果存在,请先清除所有原先安装的Perl/Tk!

如果你原来曾经安装使用过Tk,你可能需要再使用原来的Makfile文件执行如下:

make uninstall

make realclean

注:此操作应该在你解开新版本的包之前(另外,请注意这里make的uninstall属性相对比较新)。

l 让Perl按照你的系统情况产生一个Makefile文件

perl Makefile.PL

(注:关于此步骤地详细说明请参阅下面的部分)。

l 编译

make

(注:只有在做静态编译的时候才使用:make tkperl)

l 测试

make test

l 安装

make install

l 开始使用

basic_demo(译者注:建议直接使用perl basic_demo)

(注:请根据需要修改首行#!后面的内容,或指定/path/to/perl ./basic_demo)

(警告:如果你使用的是Tk-b9.01和perl5.002gamma,请把basic_demo中的use lib ./blib;行改成use lib qw(blib/arch blib/lib);)

l 把这些文档和例子保存到一个安全可用的地方

你可以使用tar,cp,mv,chmod等等一些命令来把Tk安装目录里的这些有用的辅助文件保存起来。

另外,在“perl Makefile.PL”的一步中,有时可能需要明确指明X11库或头文件的位置。例如:

perl Makefile.PL X11=/usr/local/X11R5

或者,可能你的X安装的头文件和库在其它不同的目录中:

perl Makefile.PL X11INC=/usr/local/share/X11R5/include X11LIB=/usr/local/arch/X11R5/lib

以上的所有步骤实际的成功与否实际主要依赖于你的系统。但是,最多的安装错误通常是由于没有使用最新版本的各种工具而造成的(例如C编译器、make等等)。特别是在你执行“perl Makefile.PL”前,先确定你调用的是哪里的perl(用which perl)以及它的版本(用perl -v)。如果必要的话,甚至可以给出你的Perl5解释器的全路径(因为,有些人在升级perl的时候并没有删除掉老的版本,所以要特别小心)。

如果你的安装仍有问题,阅读一下INSTALL文件、README文件和与你的系统对应的README文件(例如,README.AIX、README.OSF等等)。你可能也可以在下面的地址找到与你的系统对应的ptk的超文本档案文件:

http://www.rosat.mpe-garching.mpg.de/mailing-lists/ptk/

http://pubweb.bnl.gov/~ptk/

ftp://ftp.ccd.bnl.gov/pub/ptk/archives/

或者下面的任何一个地址:

http://www.rosat.mpe-garching.mpg.de/mailing-lists/Perl5-Porters/

http://www.hut.fi/~jhi/perl5-porters.html

如果你希望和其它人讨论你在安装Tk时遇到的问题,可以运行Tk安装目录中的myConfig脚本,并保存其输出结果(可能已经被保存在你的Tk安装目录中的myConfig.out文件中了)。同样的,运行perl安装目录中的myconfig脚本(或perl –V),并保存其结果。因为一般说来,在与别人讨论的时候,出示上面的任何一个(或全部)结果会非常有帮助的。

(译者注:原文下面的部分是一些在各种系统上发现的Tk安装中的问题,但是都已经比较老了,可能不太适用了,所以就不译了……累得不行了,偷点懒咯:P)

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有