Updated 2017-07-21 14:40:09 by MrTao

Attributes  edit


What tclreadline
Where http://tclreadline.sourceforge.net/
Latest version 2.1.0
Updated 07/2001

More recently updated forks

Summary  edit

Tcl bindings for GNU readline, by Johannes Zellner, used to enhance an interactive Tcl

Tested with Tcl 8.1 as well as itcl.

See Also  edit


Description  edit

Mike 2007-11-15:

Getting tclreadline (2.1.0) running on Mac OSX is a hassle. After running "./configure --enable-tclshrl" followed by "make", i got errors about "Undefined symbols ...". To fix it you need to do the following:

  • After you have made sure you have a recent version of the readline library (I use 5.2), you will need to make sure that the symbolic link under /usr/lib/libreadline.dylib is pointing to the right location (originally it was pointing to /usr/lib/libedit.dylib).

If you enable tclreadline in your tclsh and get an "alloc: invalid block: ..." error, then you will have to do the following:

  • Edit tclreadline.c file and rename all MALLOC to malloc and FREE to free (and remove the macros MALLOC and FREE)

PYL 2007-12-24:

  • Apparently /usr/lib/libedit.dylib is or contains libreadline as a 'nm -o /usr/lib/libedit.dylib' will show you...
  • I still cannot build tclreadline on Mac OSX. Could someone provide a link to some nice build so that I could RTFM ???
  • Build on GNU/linux was a breeze...

Will 2008-03-16:

I just managed to build tcllibreadline on Mac OS 10.4. I first did everything Mike did (note that you will need to have the proper libreadline - I had 5.2 under /usr/local/lib already but I don't think that came with the OS - and check the /usr/lib/libreadline.dylib symlink isn't incorrect). In addition I had to:

  • set the environment variable MACOSX_DEPLOYMENT_TARGET to 10.4 (I used "setenv MACOSX_DEPLOYMENT_TARGET 10.4" but I use tcsh - always forget the bash syntax).
  • link glibtool into the build directory with "ln -s /usr/bin/glibtool libtool" as the configure scripts weren't able to create their own.

[Chap] 2010-01-20 23:03:18:

Things I did to install libtclreadline-2.1.0 and readline-6.1 on Mac OS X 10.6.2 with TCL 8.5 that came with OSX.

  • built a libreadline.dylib by downloading readline-6.1.tar.gz from http://tiswww.case.edu/php/chet/readline/rltop.html, and following the README. (It's standard procedure: from Terminal, navigate into the readline-6.1 directory, enter './configure', and 'make'.) DON'T 'make install', however.
  • /usr/lib/libreadline.dylib is a symlink to /usr/lib/libedit.dylib. On the recommendation of someone at the Apple Discussions Unix forum, I renamed the symlink to /usr/lib/libreadline_OLD.dylib and moved my newly-built libreadline.dylib (from previous step) into /usr/lib/. Needed sudo, of course.
  • built a libtclreadline.dylib by downloading it from http://tclreadline.sourceforge.net/. (Migraine sufferers are cautioned about the page's color scheme.) Unfortunately, this package is so old it needs some tweaks to get it to build a dylib:

From etresoft on Apple Discussions forum:

... the tclreadline library uses old versions of autoconf. Before calling "./configure" on this project, run "autoreconf -fvi". That will enable shared libraries.

Quite correct - and there's one more thing to do before building.

If you enable tclreadline in your tclsh and get an "alloc: invalid block: ..." error, then you will have to do the following: Edit tclreadline.c file and rename all MALLOC to malloc and FREE to free (and remove the macros MALLOC and FREE)

Having done that, I then ran './configure', 'make', and 'sudo make install'

-- From tclreadline.sourceforge.net:

If you want to use tclreadline as a line interface for developing tcl scripts, you probably don't have to read much of the following section. Just install the package and put the following lines to your $HOME/.tclshrc:
if {$tcl_interactive} {
    package require tclreadline 

My goal was simply to be able to run 'tclsh -i' and have a modern command line for learning and experimenting with TCL. So I did exactly what's described above.

-- It worked. I hope this helps somebody.

[bovine] 2010-05-03 16:56:50:

These steps are a modified version of Chap's instructions so that you do not have to replace the system libreadline. Tested on MacOS X 10.6.3

Download these two tarballs:

Run these commands:
cd ~/

tar xvzf ~/Downloads/readline-6.1.tar.gz

tar xvzf ~/Downloads/tclreadline-2.1.0.tar.gz

cd ~/readline-6.1/

./configure --disable-shared --prefix=/tmp/readline-install/


make install

cd ~/tclreadline-2.1.0/

autoreconf -fvi

./configure --with-readline-includes=/tmp/readline-install/include/readline --with-readline-library=/tmp/readline-install/lib/libreadline.a

egrep -v '#define (FREE|MALLOC)' tclreadline.c | sed 's/MALLOC/malloc/; s/FREE/free/' > tclreadline.c.new

mv -f tclreadline.c.new tclreadline.c


sudo make install

rm -rf /tmp/readline-install

hv: Thank you. I followed bovine's instruction and finally got tclreadline to build, installed, and was able to use it. Great instruction.

Debian/Ubuntu offer tclreadline as standard packages, installable via the package manager. After installing tclreadline, a new file .tclshrc must be created in the home directory with following content (same as above):
if {$tcl_interactive} {
    package require tclreadline

[sathwikm91] - 2017-02-10 02:21:55

sath: I tried the above procedure by bovine on my mac OS Sierra Version 10.12.2: I am getting this error when I run 'make install' clang: error: invalid argument '-compatibility_version 6' only allowed with '-dynamiclib' Nevertheless when I continue I am getting this error when I run 'autoreconf -fvi': -bash: autoreconf: command not found. Later when I run just 'make' and 'sudo make install' I am getting this error: libtool: link: cannot build libtool library `libtclreadline.la' from non-libtool objects: /tmp/readline-install/lib/libreadline.a make: *** [libtclreadline.la] Error 1

Please help. Newbie here.

[MrTao] - 2017-07-21 14:40:09

I have created a pull request for tclreadline to be included in Homebrew to make interaction with tclsh less painful experience on macOS.