tdlib / td

Cross-platform library for building Telegram clients
https://core.telegram.org/tdlib
Boost Software License 1.0
7.24k stars 1.47k forks source link

td/tdutils/generate/generate_mime_types_gperf.cpp:7:10: fatal error: 'algorithm' file not found #1162

Closed maximveksler closed 4 years ago

maximveksler commented 4 years ago

Hello, trying to get tdlib to compile, not very successfully so far.

I'm on Ubuntu 20.04.

I got all the basic install instructions from https://tdlib.github.io/td/build.html?language=Go, i.e.

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install make git zlib1g-dev libssl-dev gperf php cmake clang-6.0 libc++-dev libc++abi-dev
git clone https://github.com/tdlib/td.git
cd td
git checkout v1.6.0
rm -rf build
mkdir build
cd build
export CXXFLAGS="-stdlib=libc++"
CC=/usr/bin/clang-6.0 CXX=/usr/bin/clang++-6.0 cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX:PATH=../tdlib -DCMAKE_AR=/usr/bin/llvm-ar-6.0 -DCMAKE_NM=/usr/bin/llvm-nm-6.0 -DCMAKE_OBJDUMP=/usr/bin/llvm-objdump-6.0 -DCMAKE_RANLIB=/usr/bin/llvm-ranlib-6.0 ..
cmake --build . --target install

It failed with:

maxim@maxim-ThinkPad-E480:~/projects/td/build$ cmake --build . --target install
Scanning dependencies of target git_commit
[  0%] Generate git_commit.h
[  0%] Built target git_commit
Scanning dependencies of target generate_mime_types_gperf
[  0%] Building CXX object tdutils/generate/CMakeFiles/generate_mime_types_gperf.dir/generate_mime_types_gperf.cpp.o
/home/maxim/projects/td/tdutils/generate/generate_mime_types_gperf.cpp:7:10: fatal error: 'algorithm' file not found
#include <algorithm>
         ^~~~~~~~~~~
1 error generated.
make[2]: *** [tdutils/generate/CMakeFiles/generate_mime_types_gperf.dir/build.make:63: tdutils/generate/CMakeFiles/generate_mime_types_gperf.dir/generate_mime_types_gperf.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:726: tdutils/generate/CMakeFiles/generate_mime_types_gperf.dir/all] Error 2
make: *** [Makefile:141: all] Error 2

Attempts

I figured I best add sudo apt install libstdc++-10-dev, same error. Then I tried to uncomment set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") from CMakeLists.txt, same error.

LD config:

maxim@maxim-ThinkPad-E480:~/projects/td$ find /etc/ld.so.conf.d/ -type f -exec echo {} \; -exec cat {} \; -exec echo '' \;
/etc/ld.so.conf.d/fakeroot-x86_64-linux-gnu.conf
/usr/lib/x86_64-linux-gnu/libfakeroot

/etc/ld.so.conf.d/i386-linux-gnu.conf
# Multiarch support
/usr/local/lib/i386-linux-gnu
/lib/i386-linux-gnu
/usr/lib/i386-linux-gnu
/usr/local/lib/i686-linux-gnu
/lib/i686-linux-gnu
/usr/lib/i686-linux-gnu

/etc/ld.so.conf.d/zz_i386-biarch-compat.conf
# Legacy biarch compatibility support
/lib32
/usr/lib32

/etc/ld.so.conf.d/x86_64-linux-gnu.conf
# Multiarch support
/usr/local/lib/x86_64-linux-gnu
/lib/x86_64-linux-gnu
/usr/lib/x86_64-linux-gnu

/etc/ld.so.conf.d/libc.conf
# libc default configuration
/usr/local/lib

Any help please?

maximveksler commented 4 years ago
maxim@maxim-ThinkPad-E480:~/projects/td$ find /usr/ | grep include | grep algorithm
/usr/include/c++/10/ext/algorithm
/usr/include/c++/10/algorithm
/usr/include/c++/10/bits/algorithmfwd.h
/usr/include/c++/10/experimental/algorithm
/usr/include/c++/10/pstl/glue_algorithm_defs.h
/usr/include/c++/10/pstl/algorithm_fwd.h
/usr/include/c++/10/pstl/glue_algorithm_impl.h
/usr/include/c++/10/pstl/algorithm_impl.h
/usr/include/c++/10/parallel/algorithm
/usr/include/c++/10/parallel/algorithmfwd.h
/usr/include/c++/9/ext/algorithm
/usr/include/c++/9/algorithm
/usr/include/c++/9/bits/algorithmfwd.h
/usr/include/c++/9/experimental/algorithm
/usr/include/c++/9/pstl/glue_algorithm_defs.h
/usr/include/c++/9/pstl/algorithm_fwd.h
/usr/include/c++/9/pstl/glue_algorithm_impl.h
/usr/include/c++/9/pstl/algorithm_impl.h
/usr/include/c++/9/parallel/algorithm
/usr/include/c++/9/parallel/algorithmfwd.h
/usr/lib/llvm-10/include/c++/v1/algorithm
/usr/lib/llvm-10/include/c++/v1/experimental/algorithm
/usr/lib/llvm-6.0/lib/clang/6.0.1/include/cuda_wrappers/algorithm
maximveksler commented 4 years ago

I'd like to point out that switching to g++ based build system does seem to work (so far..)

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install make git zlib1g-dev libssl-dev gperf php cmake g++
git clone https://github.com/tdlib/td.git
cd td
git checkout v1.6.0
rm -rf build
mkdir build
cd build
export CXXFLAGS=""
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX:PATH=../tdlib ..
cmake --build . --target install
levlam commented 4 years ago

Use

sudo apt-get install clang-10

And then replace everywhere "-6.0" wirh "-10".

maximveksler commented 4 years ago

Thanks @levlam,

I've sudo apt remove libstdc++-10-dev

and

sudo apt update
sudo apt upgrade
sudo apt install make git zlib1g-dev libssl-dev gperf php cmake clang-10 libc++-dev libc++abi-dev
git clone https://github.com/tdlib/td.git
cd td
git checkout v1.6.0
rm -rf build
mkdir build
cd build
export CXXFLAGS="-stdlib=libc++"
CC=/usr/bin/clang-10 CXX=/usr/bin/clang++-10 cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX:PATH=../tdlib -DCMAKE_AR=/usr/bin/llvm-ar-10 -DCMAKE_NM=/usr/bin/llvm-nm-10 -DCMAKE_OBJDUMP=/usr/bin/llvm-objdump-10 -DCMAKE_RANLIB=/usr/bin/llvm-ranlib-10 ..
cmake --build . --target install

so far seems to be working.

Should I close this issue or keep it open for a fix to be applied in the branch?

levlam commented 4 years ago

The build instructions are already fixed in the private repository. The fix will be pushed to Github next week.

levlam commented 4 years ago

Fixed in master.