d99kris / nchat

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

[Bug] Linking fails on Raspberry Pi #23

Closed alohawolf closed 4 years ago

alohawolf commented 4 years ago

register@raspberrypi:~/nchat/build $ uname -a Linux raspberrypi 4.19.97-v7l+ #1294 SMP Thu Jan 30 13:21:14 GMT 2020 armv7l GNU/Linux

register@raspberrypi:~/nchat/build $ lsb_release --all No LSB modules are available. Distributor ID: Raspbian Description: Raspbian GNU/Linux 10 (buster) Release: 10 Codename: buster

[100%] Building CXX object CMakeFiles/nchat.dir/src/uidefault.cpp.o [100%] Building CXX object CMakeFiles/nchat.dir/src/uilite.cpp.o [100%] Building CXX object CMakeFiles/nchat.dir/src/util.cpp.o [100%] Linking CXX executable bin/nchat /usr/bin/ld: lib/libtdutils.a(logging.cpp.o): in function std::atomic<double>::store(double, std::memory_order)': /usr/include/c++/8/atomic:239: undefined reference toatomic_store_8' /usr/bin/ld: lib/libtdclientshared.so: undefined reference to `atomic_fetch_add_8' /usr/bin/ld: lib/libtdclientshared.so: undefined reference to __atomic_load_8' /usr/bin/ld: lib/libtdclientshared.so: undefined reference to__atomic_fetch_sub_8' collect2: error: ld returned 1 exit status make[2]: [CMakeFiles/nchat.dir/build.make:230: bin/nchat] Error 1 make[1]: [CMakeFiles/Makefile2:111: CMakeFiles/nchat.dir/all] Error 2 make: *** [Makefile:130: all] Error 2

alohawolf commented 4 years ago

fullcompile.log

d99kris commented 4 years ago

Looks like there are similar build problems for other softwares as well, for example https://github.com/alexa/avs-device-sdk/issues/1404

Looks like the linking flags in some CMakeLists.txt file needs to be adjusted, but I don't have a Raspberry Pi to test on. Possibly you can try add a line like this:

set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -latomic")

Meanwhile I'll see if I can get a chance to try Raspbian in VirtualBox (it's not ARM, but maybe I'll get the same linking error).

d99kris commented 4 years ago

Raspbian in VirtualBox on amd64 builds fine. Tried building arm64 on Travis-CI but it failed due to build taking too long: https://travis-ci.com/d99kris/nchat/builds/150189142

Might try to see if there's some QEMU Raspberry Pi image that can run with reasonable speed on my amd64 systems.

d99kris commented 4 years ago

The "off-the-shelf" instructions for QEMU I found only gives me a 265MB RAM Arm system which is insufficient to build the Telegram library (tdlib). So I'm not able to reproduce the bug at this point (as I don't have access to a Raspberry Pi).

Hopefully distros start providing tdlib pre-built soon, and then nchat build could be simplified.

d99kris commented 4 years ago

I tested a Scaleway ARM64-8GB VPS, and it builds nchat successfully. System info:

d99kris@sw01:~$ uname -a
Linux sw01 4.19.0-6-arm64 #1 SMP Debian 4.19.67-2+deb10u2 (2019-11-11) aarch64 GNU/Linux
d99kris@sw01:~$ lsb_release --all
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 10 (buster)
Release:    10
Codename:   buster

I've looked for Raspberry Pi VPS services, but I couldn't find any available.

d99kris commented 4 years ago

Finally got my hands on a Raspberry Pi VPS from https://www.ikoula.com/en/raspberry-pi-4-micro-server and implemented/tested a proper fix for this. Tested OK on:

$ uname -a
Linux frhb44320ds 4.19.97-v7l+ #1294 SMP Thu Jan 30 13:21:14 GMT 2020 armv7l GNU/Linux
$ lsb_release --all
No LSB modules are available.
Distributor ID: Raspbian
Description:    Raspbian GNU/Linux 10 (buster)
Release:    10
Codename:   buster