Chinaunix首页 | 论坛 | 博客
  • 博客访问: 215408
  • 博文数量: 127
  • 博客积分: 1998
  • 博客等级: 上尉
  • 技术积分: 1432
  • 用 户 组: 普通用户
  • 注册时间: 2011-12-07 16:41
文章分类

全部博文(127)

文章存档

2014年(41)

2013年(1)

2012年(85)

分类: LINUX

2012-06-17 13:47:49

If you wish to compile with Readline support and your unix-like system does not have the Readline library installed, follow the tips here to help with Readline installation. Most Linux installations will have the readline library installed already and all you need to do is uncomment the two lines in the Makefile:

READLINE = -DREADLINE_SUPPORT READLINELIB = -lreadline -lcurses

On recent versions of Linux, if this doesn't work, then you may have to install the readline development libraries with a command like:

yum install readline-devel (RPM-based systems) apt-get install libreadline5-dev (Debian-based systems)

If this doesn't work, or you are using another Unix system then proceed as follows:

Download the latest version of GNU readline from   At the time of writing, this is readline-6.0.tar.gz

Unpack the gzipped tar file under /tmp

cd /tmp tar -zxvf readline-6.0.tar.gz

Change to the directory this creates and run configure:

cd readline-6.0 ./configure

If you do not have write access to the /usr/local/ hierarchy, then you can install the files somewhere else:

./configure --prefix=/home/my-user-name/packages

Now build the readline library

make

and install (become superuser first if installing under /usr/local)

make install

Now, ensure that the directory where the library has been installed (/usr/local/lib/ by default) is in the search path. You can do this by setting the environment variable LD_LIBRARY_PATH

(csh) setenv LD_LIBRARY_PATH /usr/local/lib (sh) export LD_LIBRARY_PATH=/usr/local/lib

Alternatively, if you have root access, you can edit the file /etc/ld.so.conf to add the directory in which the library has been installed. Under recent Linux installations, there is another alternative which is to create a file /etc/ld.so.conf.d/readline.conf just containing a single line with the directory where the library has been installed. In either case, you must now (as root) type the command:

/sbin/ldconfig

Now, modify the Makefile, such that this directory is in the linker's library path. Change:

READLINELIB = -lreadline -lcurses

to:

READLINELIB = -L/usr/local/lib -lreadline -lcurses

Now build with make as usual, but endure that LD_LIBRARY_PATH is set whenever you want to run the program. Alternatively, install with

./configure --prefix=/usr/lib

to install in the main system directories and then it will be in the default search path. This isn't recommended unless you know what you are doing!

You can also link the readline library statically to ensure portability to machines with Linux machines having different versions of the readline library installed. In this case you will not need the LD_LIBRARY_PATH or changes to /etc/ld.so.conf. To do this, edit the Makefile and change:

READLINELIB = -lreadline -lcurses

to

READLINELIB = /usr/lib/libreadline.a -lcurses

(changing /usr/lib/ as required to point to wherever libreadline has been installed).

阅读(1181) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

buaahennande2013-05-22 21:54:54

问什么我安装了之后出现了这个问题呢?
Forread.c:(.text+0x2d): undefined reference to `set_prompt'
Forread.c:(.text+0x3c): undefined reference to `readline'
难不成要再生命一遍这个函数?