d99kris / nchat

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

compile error: ‘sort’ was not declared in this scope; did you mean ‘qsort’? #48

Closed recrunchi closed 2 years ago

recrunchi commented 2 years ago

hi.

Yesterday i compiled it just fine, but today, after tdlib update, cannot compile.

I'm using the Low Memory / RAM Systems method, so i executed the "php SplitSource.php" command, and then start make with Release mode (i have a rpi4-4gb, without doing this, compilation aborts due to process being killed because out of memory)

Now i have this problem:


[ 78%] Building CXX object lib/tgchat/ext/td/CMakeFiles/tdcore.dir/td/telegram/StickersManager3.cpp.o In file included from /data/nchat/lib/tgchat/ext/td/td/telegram/StickersManager2.cpp:46: /data/nchat/lib/tgchat/ext/td/tdutils/td/utils/algorithm.h: In instantiation of ‘void td::unique(V&) [with V = std::vector<std::__cxx11::basic_string, st d::allocator<std::__cxx11::basic_string > >]’: /data/nchat/lib/tgchat/ext/td/td/telegram/StickersManager2.cpp:346:28: required from here /data/nchat/lib/tgchat/ext/td/tdutils/td/utils/algorithm.h:97:7: error: ‘sort’ was not declared in this scope; did you mean ‘qsort’? 97 | sort(v.begin(), v.end(), std::less()); | ~~^~~~~~~~~ | qsort make[2]: *** [lib/tgchat/ext/td/CMakeFiles/tdcore.dir/build.make:3296: lib/tgchat/ext/td/CMakeFiles/tdcore.dir/td/telegram/StickersManager2.cpp.o] Error 1

Thanks, Sergio.

d99kris commented 2 years ago

Hi Sergio, I suspect there could be some issue with SplitSource.php, but I'm not sure. I tested it locally on my machine, and it can compile. I don't have an ARM/GCC-based system to test on though.

Could you perhaps zip up some of the files that SplitSource generated

zip -r stickersmanager.zip lib/tgchat/ext/td/td/telegram/StickersManager*

and share it, for example by emailing to d99kris at gmail dot com (I don't think Github Issues allows zip attachments?). Also if you could share output of uname -a and g++ -v it would be good.

To temporarily work around the issue, you could try one of the following:

  1. Download the attached patch-algorithm.txt and apply it git apply patch-algorithm.txt in your nchat clone, and see if it fixes the compilation error.

  2. Try install and build using clang++ and try build without doing the SplitSource step. clang++ uses less RAM and should be able to build on a 4 GB RAM system.

d99kris commented 2 years ago

Hi again, FYI - I did manage to get access to a Raspberry Pi 4 (4 GB) and it compiles latest nchat without issues. Irrespective of whether SplitSource.php has been used or not.

Edit: Adding my system details. It would be interesting to know your system details for comparison.

OS version:

# cat /etc/os-release 
PRETTY_NAME="Raspbian GNU/Linux 10 (buster)"
...

Kernel:

# uname -a
Linux nnn 5.10.63-v7l+ #1496 SMP Wed Dec 1 15:58:56 GMT 2021 armv7l GNU/Linux

GCC:

# g++ --version
g++ (Raspbian 8.3.0-6+rpi1) 8.3.0

RAM:

# free -h
              total        used        free      shared  buff/cache   available
Mem:          3.7Gi        42Mi       3.2Gi       3.0Mi       514Mi       3.6Gi
Swap:          99Mi        18Mi        81Mi

Disk:

# df -h /
Filesystem      Size  Used Avail Use% Mounted on
/dev/root        15G  2.2G   12G  17% /
d99kris commented 2 years ago

I found an issue with the low memory systems build steps which I've fixed in the above commit.

I propose deleting your old clone (entire nchat directory) and do a fresh git clone and follow the updated steps in https://github.com/d99kris/nchat#low-memory--ram-systems

I suspect there was some old build artefacts from previous tdlib version, that might've caused the compilation error.

This issue has been closed now. Feel free to re-open for follow-up questions, or if the compilation error still persists.