如何编译tcl&tk

原文: http://www.tcl.tk/doc/howto/compile.html#unix

暂时没有时间翻译此文,贴至此处,供大家参考。

This page provides a "how to" guide for compiling Tcl from a source distribution. Tcl has been ported to a wide variety of platforms, and compilation has been made easier through GNU autoconf on UNIX.

Before You Start

Before trying to compile Tcl you should do the following things:

  • Try ActiveTcl. ActiveState provides easy-to-install binaries of Tcl for many platforms.
  • Make sure you have the most recent patch release (8.5.2). Look in the FTP directory from which you retrieved this distribution to see if it has been updated with patches. Patch releases fix bugs, so you should normally use the latest patch release for the version of Tcl that you want.

Source Code Organization

Each Tcl component has its source organized into the following structure, which is illustrated in the figure below:

  • doc Contains manual pages in a variety of formats.
  • generic Contains source code that is common for all platforms (.c and .h files)
  • library Contains a library of Tcl scripts used by the component.
  • macosx Contains Macintosh-specific files and XCode project files.
  • tests Contains a test suite.
  • tools Contains a collection of tools used when generating Tcl distributions. (Tcl only.)
  • unix Contains UNIX-specific source code and configure and Makefiles used for building on UNIX (including Mac OS X). You can create subdirectories of the unix directory if you want to build for multiple versions of UNIX.
  • win Contains Windows-specific source code and Makefiles used for compiling with VC++ or mingw (gcc).

Installed Software Organization

When you install Tcl, it ends up in a different organization that supports an installation for multiple operating systems and machine types. You can define architecture-specific subdirectories (e.g., solaris-sparc) that contain programs and binary object files for that platform. The directory structure also supports installation of various Tcl extensions so they can be automatically found by the Tcl shell programs. For example, any subdirectory of the install/lib directory is searched for Tcl script packages, and any shared libraries in the architecture-specific lib directory can be dynamically loaded into the Tcl shells.

After installation, Tcl files are kept in the following structure:

  • doc Contains manual pages in a variety of formats.
  • lib Contains subdirectories for each Tcl package that contain their Tcl script files.
  • lib/tcl8.5 The installed Tcl script library
  • linux-ix86 Contains compiled shells and libraries for Linux.
  • solaris-sparc Contains compiled shells and libraries for Solaris.
  • solaris-sparc/lib Contains runtime libraries (.so files) for Solaris.
  • solaris-sparc/bin Contains executable shells (tclsh8.5, wish8.5) for Solaris.

Configuring and Compiling on UNIX

Compiling Tcl on UNIX has two steps: configure and make. In the simplest case you type the following commands to your shell:

  cd tcl8.5.0/unix
  configure options
  make
  make test
  make install
Configure

The configure script tests your system for different compilation and linking options and generates a Makefile. The configure script is created by GNU autoconf. There are two commonly-specified configure options:

--prefix=directory
This flag specifies the installation directory. The default is /usr/local.
--exec-prefix=directory
This flag specifies the installation directory for architecture-specific (i.e., binary) files. The default is to install architecture-specific files into the location specified by --prefix. This is typically set to a subdirectory of the main prefix, (e.g., /usr/local/solaris-sparc) for sites that want to maintain binaries for multiple architectures. If you just have a single system type, then you can ignore this option.

Note: be sure to use only absolute path names (those starting with "/") in the --prefix and --exec-prefix options.

To install into the directories /home/user/tcl/bin and /home/user/tcl/lib, for example, you should configure with:

  configure --prefix=/home/user/tcl

Tcl's configure supports several options in addition to the standard ones. Calling configure --help will list them all, but common options are:

--enable-threads
If this switch is set, Tcl will compile itself with multithreading support.
--enable-shared
If this switch is specified (the default), Tcl will compile itself as a shared library if it can figure out how to do that on this platform. Add =no will create a static build.
--enable-symbols
If this switch is specified, Tcl will build with debugging symbols.

If you wish to specify a particular compiler, set the CC environment variable before calling configure. You can also specify CFLAGS prior to configure and they will be used during compilation.

Configuring for multiple architectures

Suppose you are building for two platforms, Linux and Solaris, and your installation will be shared by both kinds of hosts. You'll want to use the --exec-prefix configure option to specify different binary installation directories.

There are two ways you can build for multiple platforms. The first way is to build both platforms in the unix subdirectory. First configure and build for one platform. After you install, type make distclean and then configure and build for the second platorm. Be sure that both the configure and build steps are run on the platform for which you are building. For example, don't configure under Solaris and then build under HP-UX.

You can also build the different platforms in different subdirectories of the unix directory. If you do this, then you must name the configure script with a full pathname. For example:

  cd /home/user/src/tcl8.5.0/unix
  mkdir solaris
  cd solaris
  /home/user/src/tcl8.5.0/unix/configure /  
	--prefix=/usr/local / 
	--exec-prefix=/usr/local/solaris-sparc
Configuring Tk

When you configure Tk you may need to tell it where Tcl was built with the --with-tcl flag. This is true, for example, if you build Tcl in a subdirectory of unix as just described. To configure Tk:

  cd /home/user/src/tk8.5.0/unix
  mkdir solaris
  cd solaris
  /home/user/src/tk8.5.0/unix/configure / 
	--with-tcl=/home/user/src/tcl8.5.0/unix/solaris / 
	--prefix=/usr/local / 
	--exec-prefix=/usr/local/solaris-sparc
Building with Make

What is Make?

After you configure your Makefile, type "make". This will create a library archive called libtcl.a or libtcl.so and an interpreter application called tclsh that allows you to type Tcl commands interactively or execute script files. When you build Tk, you create libtk.a or libtk.so and the wish executable.

Type "make test" to run an exhaustive test suite. In most cases there should not be test failures. The Tk test suite, however, does have some tests that depend on font metrics and the window manger, which can vary across platforms. The README file in the tests subdirectory has documentation about the test suite.

Type "make install" to install Tcl binaries and script files in the directories you specified with --prefix or --exec-prefix during the configure step. You'll need write permission on the installation directories to do this.

If you have trouble compiling Tcl, check out the platforms list. This is an on-line database of porting information. We make no guarantees that this information is accurate, complete, or up-to-date, but you may find it useful. If you get Tcl running on a new configuration, we would be happy to receive new information to add to the database. We're also interested in hearing how to change the configuration setup so that Tcl compiles out of the box on more platforms.

Compiling on Windows

In order to compile Tcl for Windows, you need the following items:

  • Tcl 8.5.2 source distribution (or the latest patch release)
  • MS Visual C++ 6.x or greater.

In the win subdirectory of the source release, you will find makefile.vc. This is the makefile for the Visual C++ compiler. You should update the paths at the top of the file to reflect your system configuration. Now you can use make (or nmake for VC++) to build the tcl libraries and the tclsh executable.

In order to use the binaries generated by these makefiles, use

  make install

to place the Tcl script library files someplace where Tcl can find them. Tcl looks in the following places for the library files:

  1. The path specified in the environment variable TCL_LIBRARY.
  2. Relative to the directory containing the current .exe. Tcl will look for a directory ../lib/tcl8.5 relative to the directory containing the currently running .exe.

Note that in order to run tclsh85.exe, you must ensure that tcl85.dll is on your path in the system directory, or in the directory containing tclsh85.exe.

Compiling Tk for windows follows a similar process. You must compile Tcl before you compile Tk.

If you are compiling a Tcl extension for windows, please see the TEA reference.

Compiling for Macintosh

Tcl 8.4 was the last version to support Mac Classic (OS <= 9). See the READMEs in the sources for Mac Classic build support. For Mac OS X, use the unix instructions above, with consideration for the following extra options:

--enable-framework
Builds the shared libraries as Mac OS X Frameworks.
--enable-aqua
Target the Aqua windowing system instead of X11 on Mac OS X.
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
目录回到顶部↑第一部分 tcl基础 第1章 tcl的基本概念 1.1 tcl命令 1.2 hello,world! 1.3 变量 1.4 命令替代 1.5 数学表达式 1.6 反斜杠替代 1.7 花括号和双引号的组合 1.8 过程 1.9 阶乘举例 1.10 有关变量的更多细节 1.11 有关数学表达式的更多细节 1.12 注释 1.13 替代和组合总结 1.14 要点 1.15 参考 第2章 开始 2.1 source命令 2.2 unix tcl脚本 . 2.3 windows95开始菜单 2.4 macintosh和resedit 2.5 console命令 2.6 命令行参数 2.7 预定义变量 第3章 guestbook cgi程序 3.1 html快览 3.2 cgi动态页 3.3 guestbook.cgi脚本 3.4 定义表格及处理表格数据 3.5 下一步 第4章 tcl字符串处理 4.1 string命令 4.2 字符串和表达式 4.3 append命令 4.4 format命令 4.5 scan命令 4.6 字符串匹配 4.7 binary命令 4.8 相关章节 第5章 tcl列表 5.1 tcl列表 5.2 构造列表 5.3 获取列表元素:llength、1index和1range。 5.4 修改列表:1insen和lreplace 5.5 搜索列表:lsearch 5.6 列表排序:1sort 5.7 join命令 5.8 相关章节 第6章 控制结构命令 6.1 if then else 6.2 switch 6.3 while 6.4 foreach 6.5 for命令 6.6 break和continue 6.7 catch 6.8 error 6.9 return 第7章 过程和作用域 7.1 proc命令 7.2 利用rename改变命令名 7.3 作用域 7.4 global命令 7.5 使用upvar按名称调用 7.6 使用upvar创建变量别名 第8章 tcl数组 8.1 数组语法 8.2 array命令 8.3 利用数组创建数据结构 第9章 操作文件和程序 9.1 用exec运行程序 9.2 file命令 9.3 跨平台文件命名 9.4 操作文件和目录 9.5 文件属性 9.6 输入/输出命令总结 9.7 为i/o打开文件 9.8 读写操作 9.9 当前目录——cd和pwd 9.10 用glob匹配文件名 9.11 exit和pid命令 9.12 环境变量 第二部分 tce高级编程 第10章 eval命令 10.1 利用1ist构造命令 10.2 eval内部的concat 10.3 uploevel命令 10.4 连接参数的命令 10.5 subst命令 第11章 规则表达式 11.1 规则表达式语法 11.2 regexp命令 11.3 常用的规则表达式 11.4 regsub命令 11.5 使用regsub给tcl转换数据 11.6 其他使用规则表达式的命令 第12章 脚本库和程序包 12.1 定位程序包:auto—path变量 12.2 使用程序包 12.3 package命令 12.4 基于tcllndex文件的程序库 12.5 unknown命令 12.6 交互式的便利 12.7 tcl外壳的库环境 12.8 编码风格 第13章 映像和调试 13.1 clocl命令 13.2 info命令 13.3 跨平台支持 13.4 跟踪变量数值 13.5 交互命令历史 13.6 调试 13.7 don libes的调试器 13.8 调试tk脚本 13.9 性能调整 第14章 名称空间 14.1 名称空间的用法 14.2 名称空间变量 14.3 命令查找 14.4 嵌套的名称空间 14.5 过程导入 14.6 其他名称空间 14.7 回叫和名称空间 14.8 自检 14.9 namespace命令 14.10 包装现有的程序包 14.11 [incr tcl]对象系统 14.12 注释 第15章 事件驱动编程 15.1 tcl事件循环 15.2 after命令 15.3 fileevent命令 15.4 vwait命令 15.5 fconfigure命令 第16章 stcket编程 16.1 客户socket 16.2 服务器socket 16.3 回显服务 16.4 用http获取url 16.5 http包
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值