Skip to content

cmake: Fix undefined reference build failure.

orbea requested to merge orbea/umr:curses into main

This fixes the build failure on gentoo.

[ 96%] Linking C executable umr
cd /tmp/umr/build/src/app && /usr/bin/cmake -E cmake_link_script CMakeFiles/umr.dir/link.txt --verbose=1
/usr/lib/ccache/bin/cc  -Wall -W -g3 -pedantic -Werror=format-security -Wunused-result -rdynamic CMakeFiles/umr.dir/main.c.o -o umr  -Wl,-rpath,/usr/lib/llvm/11/lib64: libumrapp.a ../lib/lowlevel/linux/libumrlow.a ../lib/libumrcore.a ../lib/lowlevel/linux/libumrlow.a -lcurses -lform -lpciaccess /usr/lib/llvm/11/lib64/libLLVM-11.so -lpthread 
/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: libumrapp.a(top.c.o): undefined reference to symbol 'nodelay'
/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: /lib64/libtinfo.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make[2]: *** [src/app/CMakeFiles/umr.dir/build.make:111: src/app/umr] Error 1
make[2]: Leaving directory '/tmp/umr/build'
make[1]: *** [CMakeFiles/Makefile2:471: src/app/CMakeFiles/umr.dir/all] Error 2
make[1]: Leaving directory '/tmp/umr/build'
make: *** [Makefile:171: all] Error 2

I was not able to reproduce the issue on Slackware current, but it still builds fine there with this change. It must be a difference between how Slackware and gentoo build ncurses. Using -DCMAKE_EXE_LINKER_FLAGS=-ltinfo also worked around this issue, but its better to be explicit with the ncurses LDFLAGS.

Merge request reports