jlpoole Guru
Joined: 01 Nov 2005 Posts: 488 Location: Salem, OR
|
Posted: Thu May 16, 2024 5:10 pm Post subject: sys-libs/ncurses & Using ncurses6-config |
|
|
I was trying to build in Gentoo an open source project readsb which converts radio signals emitted by aircraft into information packets used to track aircraft. I ran into this error during the build process:
Code: |
cd /usr/local/src
sudo chmod 777 .
git clone https://github.com/wiedehopf/readsb.git
cd readsb
make
...
cc -o readsb readsb.o argp.o anet.o interactive.o mode_ac.o mode_s.o comm_b.o json_out.o net_io.o crc.o demod_2400.o uat2esnt/uat2esnt.o uat2esnt/uat_decode.o stats.o cpr.o icao_filter.o track.o util.o fasthash.o convert.o sdr_ifile.o sdr_beast.o sdr.o ais_charset.o globe_index.o geomag.o receiver.o aircraft.o api.o minilzo.o threadpool.o -pthread -lpthread -lm -lrt -lzstd -lz -lncurses
/usr/libexec/gcc/x86_64-pc-linux-gnu/ld: interactive.o: undefined reference to symbol 'stdscr'
/usr/libexec/gcc/x86_64-pc-linux-gnu/ld: /lib64/libtinfo.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make: *** [Makefile:158: readsb] Error 1
|
I did not know precisely what the error meant other than it looks to be relating to an attempt to link the previously compiled objects. I did find within the code that "stdscr" was referenced and I determined that "stdscr" within ncurses is:
Code: | The Standard Screen
Upon initializing curses, a default window called stdscr, which is the size of the terminal screen, is created. Many curses functions use this window.
Source: https://manpages.org/stdscr/3 |
So I looked for the symbol in the library libncurses on my Gentoo workstation:
Code: |
jlpoole@ryzdesk /usr/local/src/readsb $ nm -gD /lib64/libncurses.so.6.4 |nl|grep stdscr
311 0000000000014af0 T _nc_stdscr_of
428 U stdscr
jlpoole@ryzdesk /usr/local/src/readsb $ |
Note: the tool I used is "nm",aka "Name Mangling". See https://en.wikipedia.org/wiki/Nm_(Unix)
I also tried building the project on Debian and I succeeded. So I compared the search for the symbol on both systems:
On the Rpi4:
Code: | jlpoole@adsbDEV:/run/readsb $ nm -gD /usr/lib/arm-linux-gnueabihf/libncurses.so.6.2 |grep stdscr
U stdscr@NCURSES6_TINFO_5.0.19991023
jlpoole@adsbDEV:/run/readsb $ nm -gD /usr/lib/arm-linux-gnueabihf/libncurses.so.6 |grep stdscr
U stdscr@NCURSES6_TINFO_5.0.19991023
jlpoole@adsbDEV:/run/readsb $ |
On Debian:
Code: |
jlpoole@debian1:~$ nm -gD /usr/lib/x86_64-linux-gnu/libncursesw.so.6.4 |grep stdscr
U stdscr@NCURSES6_TINFO_5.0.19991023
jlpoole@debian1:~$ |
Gnu's nm tells me "U" is a symbol type meaning: "The symbol is undefined." But in the Raspian and Debian image, there is something more, e.g. "@...", than what was in Gentoo's library.
As I searched around, I read somewhere that ncurses may be compiled into two libraries and after scouring my Gentoo system with:
I discovered the tool "ncurses6-config" which I was not familiar with. I learned one of the options, i.e. "--libs", revealed a query which "echos the libraries needed to link with ncurses". The output below shows that "-ltinfo" was listed, so I tried adding at the end " -ltinfo" to the linker command of the failing command line and the linker successfully created the object file and the "make" continued. What was needed was to specify the inclusion of libraray "tinfo" (/lib64/libtinfo.so.6.4).
Code: | jlpoole@ryzdesk /usr/local/src/readsb $ /usr/bin/ncurses6-config
Usage: ncurses6-config [options]
Options:
--prefix echos the package-prefix of ncurses
--exec-prefix echos the executable-prefix of ncurses
--cflags echos the C compiler flags needed to compile with ncurses
--libs echos the libraries needed to link with ncurses
...
jlpoole@ryzdesk /usr/local/src/readsb $ /usr/bin/ncurses6-config --libs
-L/usr/lib64 -lncurses -ltinfo
jlpoole@ryzdesk /usr/local/src/readsb $ cc -o readsb readsb.o argp.o anet.o interactive.o mode_ac.o mode_s.o comm_b.o json_out.o net_io.o crc.o demod_2400.o uat2esnt/uat2esnt.o uat2esnt/uat_decode.o stats.o cpr.o icao_filter.o track.o util.o fasthash.o convert.o sdr_ifile.o sdr_beast.o sdr.o ais_charset.o globe_index.o geomag.o receiver.o aircraft.o api.o minilzo.o threadpool.o -pthread -lpthread -lm -lrt -lzstd -lz -lncurses -ltinfo
jlpoole@ryzdesk /usr/local/src/readsb $ make
rm -f viewadsb
cp readsb viewadsb
jlpoole@ryzdesk /usr/local/src/readsb $ |
So, if people run into a problem with unsupported packages not compiling because of error messages above, then if there is a hint the problem is related to ncurses, the above may prove helpful in overcoming the problem. |
|