ncurses-rs icon indicating copy to clipboard operation
ncurses-rs copied to clipboard

undefined reference to `COLORS'

Open aplanas opened this issue 5 years ago • 3 comments

When compiling ncspot from git, I have this linker error at the end:

...
pe" "-lxcb-xfixes" "-lncursesw" "-ltinfo" "-lutil" "-lutil" "-ldl" "-lrt" "-lpthread" "-lgcc_s" "-lc" "-lm" "-lrt" "-lpthread" "-lutil" "-lutil"
  = note: /usr/lib64/gcc/x86_64-suse-linux/9/../../../../x86_64-suse-linux/bin/ld: /home/aplanas/ncspot/target/release/deps/libncurses-9568030c4c279be4.rlib(ncurses-9568030c4c279be4.ncurses.6tisobd3-cgu.4.rcgu.o): in function `ncurses::constants::COLORS':
          ncurses.6tisobd3-cgu.4:(.text._ZN7ncurses9constants6COLORS17h28f96c61a3832871E+0x3): undefined reference to `COLORS'
          collect2: error: ld returned 1 exit status

I have openSUSE Tumbleweed:

> rpm -qa | grep ncurses
ncurses-devel-6.1-24.1.x86_64
ncurses-utils-6.1-24.1.x86_64
libncurses6-6.1-24.1.x86_64

> rpm -qa | grep terminfo
terminfo-screen-6.1-24.1.x86_64
terminfo-6.1-24.1.x86_64
terminfo-base-6.1-24.1.x86_64

aplanas avatar Dec 12 '19 15:12 aplanas

Workaround: install libncurses5 and add #[link(name = "ncursesw")] to the extern block in src/ll.rs (done in my fork). Building then requires these env variables:

NCURSES_RS_RUSTC_LINK_LIB=ncursesw::libncursesw.so.5
NCURSES_RS_RUSTC_FLAGS="-L /lib64"

FliegendeWurst avatar Apr 09 '20 17:04 FliegendeWurst

I'm not sure the workaround is correct. For me, it failed to link because of conflicts in libtinfo, but I could get a working executable after installing ncurses5-devel and with the following env variable:

export NCURSES_RS_RUSTC_FLAGS="-L /usr/lib64/ncurses5"

ptesarik avatar Dec 27 '20 22:12 ptesarik

I'm not sure the workaround is correct. For me, it failed to link because of conflicts in libtinfo, but I could get a working executable after installing ncurses5-devel and with the following env variable:

export NCURSES_RS_RUSTC_FLAGS="-L /usr/lib64/ncurses5"

Thank you!!! This was killing me. I can confirm this worked and fixed the problem I was having building ncspot on OpenSuse Leap 15.2. Because the snap version gives no sound on OpenSuse Leap, this fix was required to get ncspot working.

eganonoa avatar Jan 01 '21 11:01 eganonoa