d99kris / nchat

Terminal-based Telegram / WhatsApp client for Linux and macOS
MIT License
647 stars 45 forks source link

[Bug] Linking error when building nchat on Gentoo #13

Closed bit69tream closed 2 years ago

bit69tream commented 4 years ago

It errors on 100% and I don't know why.

/usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: CMakeFiles/nchat.dir/src/uicommon.cpp.o: undefined reference to symbol 'keypad'
/usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: /lib64/libtinfow.so.6: error adding symbols: DSO missing from command line

All dependencies are installed. Distro: Gentoo Linux Compile log: https://pastebin.com/1WkqxmYY GCC/G++ version: 8.3.0

d99kris commented 4 years ago

I suspect your CMake version (cmake --version) is older than 3.10, and nchat uses a feature in CMake >= 3.10 to correctly detect one of its dependencies - libncursesw.

If possible, try upgrading CMake to a version >= 3.10, alternatively as a workaround you can change the following line in CMakeLists.txt: target_link_libraries(nchat PUBLIC tdclientshared ${CURSES_NCURSES_LIBRARY}) to: target_link_libraries(nchat PUBLIC tdclientshared ncursesw) and try build again. Please let me know if it works. Thanks.

To prevent others from encountering this issue I'll probably enforce the suitable minimum CMake version.

bit69tream commented 4 years ago

Sorry The problem was in ncurses lib

I tried to compile another project with ncurses and the error was the same

bit69tream commented 4 years ago

I fixed the problem I added target_link_libraries(nchat PUBLIC tdclientshared tinfow)

d99kris commented 4 years ago

Great to hear you found a solution. Do you mind sharing which cmake version you were using btw?

d99kris commented 2 years ago

Finally got a chance to properly look into this, as I got access to a Gentoo system. Reproduced it with below steps and result.

Steps performed:

emerge -n dev-vcs/git
git clone https://github.com/d99kris/nchat
cd nchat
emerge -n dev-util/cmake dev-util/gperf sys-apps/help2man sys-libs/readline dev-libs/openssl sys-libs/ncurses sys-libs/zlib dev-db/sqlite sys-apps/file
mkdir -p build && cd build && cmake .. && make -sj8

Result:

/usr/lib/gcc/x86_64-pc-linux-gnu/10.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: CMakeFiles/nchat.dir/src/ui.cpp.o: undefined reference to symbol 'keypad'
/usr/lib/gcc/x86_64-pc-linux-gnu/10.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: /lib64/libtinfow.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
d99kris commented 2 years ago

This has been fixed in the above commit. Build should be successful using standard commands:

mkdir -p build && cd build && cmake .. && make -s