如何在 macOS 中链接到 GNU readline 库而不是 libedit?
尝试在 macOS 上构建 Term-Readline-Gnu,失败,抱怨 libedit 并建议使用 gnu readline。我该怎么做?
这是我尝试过的尝试之一:
首先我静态构建了 GNU libreadline v6.2 但没有安装它 - 到 确保我没有搞砸同名的系统版本:
./configure --prefix=/Users/Fred/Downloads/tmp1
制作
使安装静态
然后尝试构建 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
找到“/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
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!
您使用的 libreadline 是 libedit 库。使用 GNU Readline 库。
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!
克里斯
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/libFound `/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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这里是一篇很棒的文章,解释了如何修复OP的问题只需几个简单的步骤:
brew install readline
brew link --force readline
cpanm Term::ReadLine::Gnu
brew unlink readline
检查
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
GNU readline 库似乎不在
/Users/Fred/Downloads/tmp1/lib
中。首先确保该库已安装。如果你有 Mac Ports:
在我的机器上
port
将东西安装到/opt
,所以我运行: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:
On my machine
port
installs things to/opt
, so I ran:因此,为了解决一个老问题,我刚刚解决了这个问题。
正如 MisterEd 所说,您需要 GNU readline 库。然而,当你制作
Term::Readline::Gnu
时,你还需要确保GNU readline库架构与你的perl架构兼容,因为perl使用编译器开关来编译它的模块。被编译为.在 OS X 中,如果您使用 port 或 fink 安装备用 perl,您将获得专为您的体系结构(i386 或 x86_64)编译的 perl 二进制文件。在这种情况下,MisterEd 的答案是“A-OK”。
然而,正如您从上面的输出中看到的,提问者使用的是编译为通用二进制文件的 Perl (-arch i386 -arch x86_64) - 可能是系统默认的 Perl。就我而言,我使用 perlbrew 构建更新版本的 perl,但我需要它是通用的,以便我可以将东西发送到其他 OS X 机器,因此我完成了一些工作来进行通用构建。
在这些情况下,您需要使用一些额外的开关手动编译 Gnu Readline 库。我这样做了:
GNU readline:
现在由于某种原因,make 在创建 .dylib 共享库的最后步骤之一失败,但此时它已经构建了 libreadline.a,我将其复制到 /usr/local/lib 中。
Term::Readline::Gnu:
然后我下载了 Term::Readline::Gnu 的 .tar.gz 并执行了以下操作:
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:
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: