解决编译时出现libreadline.so: undefined reference to XX

提醒:本文最后更新于 2644 天前,文中所描述的信息可能已发生改变,请仔细核实。

前几天,编译某程序,离奇出现这问题。

第一次遇到,最重要的是其实我所有编译,都自己写成脚本了。每次都没问题,这次突然就来了问题。

具体显示:

...
/usr/local/lib/libreadline.so: undefined reference to `PC'
/usr/local/lib/libreadline.so: undefined reference to `tgetflag'
/usr/local/lib/libreadline.so: undefined reference to `tgetent'
/usr/local/lib/libreadline.so: undefined reference to `UP'
/usr/local/lib/libreadline.so: undefined reference to `tputs'
/usr/local/lib/libreadline.so: undefined reference to `tgoto'
/usr/local/lib/libreadline.so: undefined reference to `tgetnum'
/usr/local/lib/libreadline.so: undefined reference to `BC'
/usr/local/lib/libreadline.so: undefined reference to `tgetstr'
collect2: ld returned 1 exit status
...

configure配置时,添加LDFLAGS="-lncurses"就好了。

不过搞完还遇到另外一个程序编译时提示

/usr/lib/libncurses.a: could not read symbols: Bad value

解决办法是在编译Ncurses时,configure配置添加--with-shared --enable-widec --without-debug还不行,就在现在要编译的程序添加--enable-m4_pattern_allow出现这个问题的主要原因据说是编译器选择x86和x86_64的问题。

当然了,可能这样做了还不行,直接干掉/usr/lib/libncurses.a也就可以了。简单粗暴。

这是浑身给我找麻烦。不知为什么会这样,只能见招拆招了。

转载请注明转自:kn007的个人博客的《解决编译时出现libreadline.so: undefined reference to XX