Installing the GNU Readline library


http://www.bioinf.org.uk/software/profit/doc/node17.html


If you wish to compile with Readline support and your unix-like systemdoes not have the Readline library installed, follow the tips here tohelp with Readline installation. Most Linux installations will havethe readline library installed already and all you need to do isuncomment 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 haveto 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 thenproceed as follows:

Download the latest version of GNU readline fromhttp://cnswww.cns.cwru.edu/php/chet/readline/rltop.html 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 thisby 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 beeninstalled. Under recent Linux installations, there is anotheralternative which is to create a file /etc/ld.so.conf.d/readline.confjust containing a single line with the directory where the library hasbeen 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'slibrary 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, installwith

      ./configure --prefix=/usr/lib

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

You can also link the readline library statically to ensureportability to machines with Linux machines having different versionsof the readline library installed. In this case you will not need theLD_LIBRARY_PATH or changes to /etc/ld.so.conf. To dothis, 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 hasbeen installed).


posted @   张同光  阅读(325)  评论(0编辑  收藏  举报
编辑推荐:
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
点击右上角即可分享
微信分享提示