How to link to the GNU readline library, not libedit on macosx?

Trying to build Term-Readline-Gnu on macosx does not complain about libedit and recommends using gnu readline. How to do it?

This is one of the attempts I tried:

At first I built GNU libreadline v6.2 statically, but did not install it - to make sure that I did not spoil the version of the system with the same name:

./configure --prefix = / Users / Fred / Downloads / tmp1

to do

make install-static

Then tried to create Term_Readline-Gnu-1.20

cmc: Term-ReadLine-Gnu-1.20 cmc $ perl Makefile.PL --includedir = / Users / cmc / Downloads / tmp1 / include --libdir = / Users / Fred / Downloads / tmp1 / lib

Found `/usr/lib/libtermcap.dylib '.

gcc-4.2 -I / Users / Fred / Downloads / tmp1 / include -arch x86_64 -arch i386 -archpc -g -pipe -fno-common -DPERL_DARWIN -fno-strict-aliasing -I / usr / local / include -DHAVE_STRING_H rlver .c -o rlver -L / Users / Fred / Downloads / tmp1 / lib -arch x86_64 -arch i386 -arch ppc -L / usr / local / lib -lreadline -ltermcap

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!

The libreadline used is the libedit library. Use the GNU Readline Library.

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!

Chris

+7
source share
3 answers

Here is a great post explaining how to fix the OP problem in a few simple steps:

brew install readline

brew link --force readline

cpanm Term::ReadLine::Gnu

brew unlink readline

Check

 brew info readline | head -1 
+7
source

It looks like the GNU readline library is not located in /Users/Fred/Downloads/tmp1/lib .

First make sure the library is installed. If you have Mac ports:

 sudo port install readline 

On my machine, port installs things in /opt , so I ran:

 perl Makefile.PL --includedir=/opt/local/include --libddir=/opt/local/lib 
0
source

So, to solve the old question, I just solved / solved this problem.

As MisterEd says, you need the GNU readline library. However, when you create Term::Readline::Gnu , you also need to make sure that the GNU readline library library is compatible with your perl architecture, since perl compiles it using compilers compiled with.

On OS X, if you install alternate perl using a port or fink, you will get a perl binary compiled only for your architecture (i386 OR x86_64). In this case, the answer of MisterEd is A-OK.

However, as you can see from the above, the questionnaire uses Perl, which was compiled as a universal binary (-arch i386 -arch x86_64) - possibly the default Perl system. In my case, I used perlbrew to create a newer version of perl, but I needed it to be universal, so I could send things to other OS X machines, so I did some work to make a universal build.

In these cases, you need to compile the Gnu Readline library manually with some additional keys. I have done this:

GNU readline:

 ./configure CFLAGS="-arch i386 -arch x86_64 -mmacosx-version-min=10.5" \ LDFLAGS="-arch i386 -arch x86_64 -mmacosx-version-min=10.5" ./configure \ --prefix=/usr/local; make 

Now, for some reason, make failed in one of the last steps, creating a shared .dylib library, but at that moment it already created libreadline.a, which I copied to / usr / local / lib.

Term :: Readline :: Gnu:

Then I downloaded .tar.gz for Term :: Readline :: Gnu and did:

 perl Makefile.PL --libdir='/usr/local/lib'; make; make install 
0
source

All Articles