7
votes

Attempting to build Term-Readline-Gnu on macosx, fails complaining about libedit and recommending to use gnu readline. How do I do that?

This is one of the attempts I have tried:

First I built GNU libreadline v6.2 statically but did not install it - to make sure I did not screw up the system version with the same name:

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

make

make install-static

Then tried to build 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 -arch ppc -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 you are using is the libedit library. Use the GNU Readline Library.

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

Chris

3

3 Answers

7
votes

Here is an awesome post explaining how to fix OP's issue in few simple steps:

brew install readline

brew link --force readline

cpanm Term::ReadLine::Gnu

brew unlink readline

Check

brew info readline | head -1
0
votes

It would appear that the GNU readline library is not 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 to /opt, so I ran:

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

So, to drudge up an old question, I just had/solved this problem.

As MisterEd says, you need the GNU readline library. However when you are making Term::Readline::Gnu, you also need to make sure that the GNU readline library architecture is compatible with your perl architecture, because perl compiles it's modules using the compiler switches that it was compiled with.

In OS X, if you install an alternate perl using port or fink, you will get a perl binary compiled just for your architecture (i386 OR x86_64). In that case, MisterEd's answer is A-OK.

However, as you can see from the output above, the questioner is using a Perl that was compiled as a universal binary (-arch i386 -arch x86_64) - probably the system default Perl. In my case, I was using perlbrew to build a newer version of perl, but I needed it to be universal so I could ship things to other OS X machines, so I had gone through some work to make a universal build.

In these cases, you need to compile the Gnu Readline library by hand with some extra switches. I did 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 on one of the final steps creating the .dylib shared library, but at that point it had already built libreadline.a, which I copied into /usr/local/lib.

Term::Readline::Gnu:

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

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