[lsb-discuss] Trying to link libreadline.a, LSB 4.0 on SLES11

Mats Wichmann mats at wichmann.us
Thu Apr 7 15:35:46 UTC 2016

On 04/07/2016 08:11 AM, Dallman, John wrote:
> I've been building the production build Parasolid solid-modelling library and its test harness to LSB standards for a long time, and it has worked well. There is also a build with a lot of debugging code compiled in that has not been built LSB until now, but I'm trying to fix that. The debugging build is used interactively much more than the production build, and has used GNU readline for many years. But that's where I'm stuck.
> Readline is not an LSB-supported library at LSB 4.0.When I link, lsbcc forces it to be linked statically, which is what I want. But then the linker can't find a bunch of other symbols:
> Warning: forcing readline to be linked statically
> /usr/lib64/libreadline.a(util.o): In function `_rl_abort_internal':
> /usr/src/packages/BUILD/readline-5.2/util.c:112: undefined reference to `__longjmp_chk'
> /usr/lib64/libreadline.a(terminal.o): In function `_rl_init_terminal_io':
> /usr/src/packages/BUILD/readline-5.2/terminal.c:498: undefined reference to `PC'
> /usr/src/packages/BUILD/readline-5.2/terminal.c:499: undefined reference to `BC'
> /usr/src/packages/BUILD/readline-5.2/terminal.c:500: undefined reference to `UP'
> /usr/src/packages/BUILD/readline-5.2/terminal.c:509: undefined reference to `PC'
> /usr/src/packages/BUILD/readline-5.2/terminal.c:510: undefined reference to `BC'
> /usr/src/packages/BUILD/readline-5.2/terminal.c:511: undefined reference to `UP'
> /usr/lib64/libreadline.a(mbutil.o): In function `mbrlen':
> /usr/include/wchar.h:399: undefined reference to `__mbrlen'
> /usr/include/wchar.h:399: undefined reference to `__mbrlen'
> /usr/lib64/gcc/x86_64-suse-linux/4.3/../../../../x86_64-suse-linux/bin/ld: ./kid.out: hidden symbol `stat' in /usr/lib64/libc_nonshared.a(stat.oS) is referenced by DSO
> /usr/lib64/gcc/x86_64-suse-linux/4.3/../../../../x86_64-suse-linux/bin/ld: final link failed: Nonrepresentable section on output
> collect2: ld returned 1 exit status
> So I seem to be missing symbols __longjmp_chk, BC, PC, UP and __mbrlen, and all of those are undefined symbols in libreadline.a.
> libc.so.6 has __longjmp_chk, and __mbrlen, but I don't know why they aren't being picked up. libc.so.6 does not have BC, PC or UP.
> My link line is:
> /opt/lsb/bin/lsbcc -m64 -Wformat -Wformat-security -D_FORTIFY_SOURCE=1 -fPIC /Parasolid/lx86/t281_test_lsb4/lsp/kernel.o /usr/local/sw_tools/lib/aga_fix.o -L/Parasolid/lx86/tools/lib/64 -lreadline /Parasolid/lx86/t281_test_lsb4/system/support_part1.so /Parasolid/lx86/t281_test_lsb4/system/support_part2.so /Parasolid/lx86/t281_test_lsb4/system/ps_part1.so /Parasolid/lx86/t281_test_lsb4/system/ps_part2.so /Parasolid/lx86/t281_test_lsb4/system/ps_part3.so /Parasolid/lx86/t281_test_lsb4/system/ps_part4.so /Parasolid/lx86/t281_test_lsb4/system/ps_part5.so /Parasolid/lx86/t281_test_lsb4/system/ps_part6.so /Parasolid/lx86/t281_test_lsb4/system/ps_part7.so /Parasolid/lx86/t281_test_lsb4/system/ps_part8.so -lncurses -lpthread -lX11 -lc -lm -ldl -Wl,-rpath,/Parasolid/lx86/tools/lib/64 -o kid.out
> main() is in kernel.o, and the code that invokes readline functions is in support_part1.so or support_part2.so.
> I'm working on 64-bit SLES11sp1, targeting LSB 4.0, with this collection of LSB packages:
> lsb-build-base-4.0.1-1
> lsb-build-c++-4.0.2-1
> lsb-build-cc-4.0.1-1
> lsb-build-desktop-4.0.1-1
> lsb-build-qt3-4.0.0-5
> lsb-build-qt4-4.0.1-1
> I'm baffled, in part because I can't find a way to look at what symbols are in what sharable libraries. nm and objdump -t refuse for several of them.

The two-letter all-caps ones typically come from libtinfo (which is part
of the ncurses build, but a separate library), and in fact I find them
there when looking.

There is some past work on making a static readline work in an LSB
context, don't know if it's gone out of date now.  It _should_ be in
http://bzr.linuxfoundation.org/lsb/devel/appbat/patches, but it looks
like our version control browser has gone dead - I'll ping licquia on
that (or hopefully he's listening here).  I've attached the patch to
this reply as a convenience.

You may also be able to use our "library battery" (a package named
lsb-build-libbat), which has a prepared libreadline.a built in the LSB
context, and thus not loaded with "illegal" symbols. Unfortunately, I
can't tell you exactly where to get a 4.0 copy of that from either. I
have a 4.1 version sitting here which I could send, if we can't find
these in the package ftp site - I didn't spot in a brief look but that
means little.

As far as hunting for symbols, I tend to use readelf, as in:

readelf -sW /usr/lib64/libtinfo.so.5.9 | grep -w BC

you have to take care that some apparent shared libraries are not... for
example libc.so and libpthread.so on the native system are not
libraries, but linker directive files and so have to hunt to find the
_real_ shared library.

Hope this helps...

-- mats

-------------- next part --------------
A non-text attachment was scrubbed...
Name: readline-6.0.patch
Type: text/x-patch
Size: 2006 bytes
Desc: not available
URL: <http://lists.linuxfoundation.org/pipermail/lsb-discuss/attachments/20160407/1037126f/attachment.bin>

More information about the lsb-discuss mailing list