td icon indicating copy to clipboard operation
td copied to clipboard

Cannot build on Centos 7

Open shortsteps opened this issue 7 years ago • 3 comments

Build fails with

"[ 15%] Building CXX object tdutils/CMakeFiles/tdutils.dir/td/utils/StringBuilder.cpp.o
/home/scortopassi/td/tdutils/td/utils/StringBuilder.cpp: In member function ‘td::StringBuilder& td::StringBuilder::operator<<(const void*)’:
/home/scortopassi/td/tdutils/td/utils/StringBuilder.cpp:210:19: error: ‘snprintf’ is not a member of ‘std’
   current_ptr_ += std::snprintf(current_ptr_, reserved_size, "%p", ptr);"

Following the TDLib build instructions generator with Java > Linu> Distro: Other.

[scortopassi@buildlib-test-serena-2 build]$ export CXXFLAGS=""
[scortopassi@buildlib-test-serena-2 build]$ cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX:PATH=../example/java/td -DTD_ENABLE_JNI=ON ..
-- The CXX compiler identification is GNU 5.3.0
-- The C compiler identification is GNU 5.3.0
-- Check for working CXX compiler: /usr/local/bin/g++
-- Check for working CXX compiler: /usr/local/bin/g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Check for working C compiler: /usr/local/bin/gcc
-- Check for working C compiler: /usr/local/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Could NOT find ccache (this is NOT an error)
-- Found OpenSSL: /usr/lib64/libcrypto.so (found version "1.0.2k")  
-- Found OpenSSL: /usr/include /usr/lib64/libssl.so;/usr/lib64/libcrypto.so
-- Performing Test HAVE_STD14
-- Performing Test HAVE_STD14 - Success
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Check if compiler accepts -pthread
-- Check if compiler accepts -pthread - yes
-- Found Threads: TRUE  
-- Performing Test HAVE_CXX_FLAG_WALL
-- Performing Test HAVE_CXX_FLAG_WALL - Success
-- Performing Test HAVE_CXX_FLAG_WEXTRA
-- Performing Test HAVE_CXX_FLAG_WEXTRA - Success
-- Performing Test HAVE_CXX_FLAG_WIMPLICIT_FALLTHROUGH_2
-- Performing Test HAVE_CXX_FLAG_WIMPLICIT_FALLTHROUGH_2 - Failed
-- Performing Test HAVE_CXX_FLAG_WPOINTER_ARITH
-- Performing Test HAVE_CXX_FLAG_WPOINTER_ARITH - Success
-- Performing Test HAVE_CXX_FLAG_WCAST_QUAL
-- Performing Test HAVE_CXX_FLAG_WCAST_QUAL - Success
-- Performing Test HAVE_CXX_FLAG_WSIGN_COMPARE
-- Performing Test HAVE_CXX_FLAG_WSIGN_COMPARE - Success
-- Performing Test HAVE_CXX_FLAG_WDUPLICATED_BRANCHES
-- Performing Test HAVE_CXX_FLAG_WDUPLICATED_BRANCHES - Failed
-- Performing Test HAVE_CXX_FLAG_WDUPLICATED_COND
-- Performing Test HAVE_CXX_FLAG_WDUPLICATED_COND - Failed
-- Performing Test HAVE_CXX_FLAG_WALLOC_ZERO
-- Performing Test HAVE_CXX_FLAG_WALLOC_ZERO - Failed
-- Performing Test HAVE_CXX_FLAG_WLOGICAL_OP
-- Performing Test HAVE_CXX_FLAG_WLOGICAL_OP - Success
-- Performing Test HAVE_CXX_FLAG_WTAUTOLOGICAL_COMPARE
-- Performing Test HAVE_CXX_FLAG_WTAUTOLOGICAL_COMPARE - Failed
-- Performing Test HAVE_CXX_FLAG_WVLA
-- Performing Test HAVE_CXX_FLAG_WVLA - Success
-- Performing Test HAVE_CXX_FLAG_WNON_VIRTUAL_DTOR
-- Performing Test HAVE_CXX_FLAG_WNON_VIRTUAL_DTOR - Success
-- Performing Test HAVE_CXX_FLAG_WUNUSED_PARAMETER
-- Performing Test HAVE_CXX_FLAG_WUNUSED_PARAMETER - Success
-- Performing Test HAVE_CXX_FLAG_WCONVERSION
-- Performing Test HAVE_CXX_FLAG_WCONVERSION - Success
-- Performing Test HAVE_CXX_FLAG_WSIGN_CONVERSION
-- Performing Test HAVE_CXX_FLAG_WSIGN_CONVERSION - Success
-- Performing Test HAVE_CXX_FLAG_WCXX14_COMPAT_PEDANTIC
-- Performing Test HAVE_CXX_FLAG_WCXX14_COMPAT_PEDANTIC - Failed
-- Performing Test HAVE_CXX_FLAG_WDEPRECATED
-- Performing Test HAVE_CXX_FLAG_WDEPRECATED - Success
-- Performing Test HAVE_CXX_FLAG_QUNUSED_ARGUMENTS
-- Performing Test HAVE_CXX_FLAG_QUNUSED_ARGUMENTS - Failed
-- Performing Test HAVE_CXX_FLAG_WODR
-- Performing Test HAVE_CXX_FLAG_WODR - Success
-- Performing Test HAVE_CXX_FLAG_FLTO_ODR_TYPE_MERGING
-- Performing Test HAVE_CXX_FLAG_FLTO_ODR_TYPE_MERGING - Success
-- Found ZLIB: /usr/lib64/libz.so (found version "1.2.7") 
-- Found ZLIB: /usr/include /usr/lib64/libz.so
-- Found JNI: /usr/lib/jvm/java/jre/lib/amd64/libjawt.so  
-- Found JNI: /usr/lib/jvm/java/include;/usr/lib/jvm/java/include/linux;/usr/lib/jvm/java/include /usr/lib/jvm/java/jre/lib/amd64/libjawt.so;/usr/lib/jvm/java/jre/lib/amd64/server/libjvm.so
-- Performing Test COMPILER_HAS_HIDDEN_VISIBILITY
-- Performing Test COMPILER_HAS_HIDDEN_VISIBILITY - Success
-- Performing Test COMPILER_HAS_HIDDEN_INLINE_VISIBILITY
-- Performing Test COMPILER_HAS_HIDDEN_INLINE_VISIBILITY - Success
-- Performing Test COMPILER_HAS_DEPRECATED_ATTR
-- Performing Test COMPILER_HAS_DEPRECATED_ATTR - Success
-- Could NOT find Readline (missing: READLINE_INCLUDE_DIR READLINE_LIBRARY) 
-- Could NOT find Readline (this is NOT an error)
-- Configuring done
-- Generating done
-- Build files have been written to: /home/scortopassi/td/build

Any idea?

  • cmake3 version 3.14.6
  • g++ (GCC) 5.3.0
  • gcc (GCC) 5.3.0

shortsteps avatar Nov 14 '19 15:11 shortsteps

snprintf must be a part of a standard С++ library shipped by default with g++ 5.3.0. I expect that something is wrong with the installed libstdc++. The g++ binary is found in /usr/local/bin/g++, but it is very likely that compiler still uses libstdc++ from /usr/include instead of the shipped with the compiler. Could you paste output of next commands on your system:

grep -r snprintf /usr
find /usr | grep stdio

levlam avatar Nov 14 '19 18:11 levlam

Thanks for your answer, here you are outputs:

$ sudo find /usr | grep stdio
/usr/bin/systemd-stdio-bridge
/usr/lib64/perl5/CORE/nostdio.h
/usr/include/bits/stdio-lock.h
/usr/include/bits/stdio-ldbl.h
/usr/include/bits/stdio.h
/usr/include/bits/stdio2.h
/usr/include/bits/stdio_lim.h
/usr/include/stdio.h
/usr/include/stdio_ext.h
/usr/include/c++/4.8.2/cstdio
/usr/include/c++/4.8.2/ext/stdio_filebuf.h
/usr/include/c++/4.8.2/ext/stdio_sync_filebuf.h
/usr/include/c++/4.8.2/tr1/cstdio
/usr/include/c++/4.8.2/tr1/stdio.h
/usr/local/gcc53/include/c++/5.3.0/ext/stdio_filebuf.h
/usr/local/gcc53/include/c++/5.3.0/ext/stdio_sync_filebuf.h
/usr/local/gcc53/include/c++/5.3.0/tr1/cstdio
/usr/local/gcc53/include/c++/5.3.0/tr1/stdio.h
/usr/local/gcc53/include/c++/5.3.0/cstdio
/usr/local/gcc53/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/include/ssp/stdio.h

Maybe should I tell compiler to use libraries in /usr/local/gcc53/include/ instead of /usr/include/ ?

The output of grep -r snprintf /usr is really weird, a huge list of "binary file xxx matches". What would you like to know?

Thanks a lot

shortsteps avatar Nov 15 '19 08:11 shortsteps

There is no reason in grep -r snprintf /usr anymore.

The problem is definitely that you have GCC 4.8.2 libstdc++ headers in /usr/include. There is no way g++ could find right headers in /usr/local/gcc53/include by itself. You can try to add line

  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -isystem /usr/local/gcc53/include/")

before https://github.com/tdlib/td/blob/a0fa744735e524956c6d55287121da69e85c8532/CMakeLists.txt#L160

But after that you are likely to get some link errors instead.

It would be better to completely replace default GCC instalation with GCC 5.3 or newer. There are instructions on how to do that in https://stackoverflow.com/questions/36327805/how-to-install-gcc-5-3-with-yum-on-centos-7-2.

levlam avatar Nov 15 '19 10:11 levlam