CMake 3.15.5 bootstrap fail with g++ 9.3.0 - linux

I'm trying to build CMake 3.15.5 on a 20.04 xubuntu machine (but I also tried 18.04 and 20.10 with the same results).
The error is as follows:
loading initial cache file /home/max/Lavori/nova/src/repos/dep-startup/buildroot-output/buildroot-2020.02.1/output/build/host-cmake-3.15.5/Bootstrap.cmk/InitialCacheFlags.cmake
-- The C compiler identification is GNU 9.3.0
-- The CXX compiler identification is GNU 9.3.0
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/g++
-- Check for working CXX compiler: /usr/bin/g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Checking if compiler supports C11 _Thread_local
-- Checking if compiler supports C11 _Thread_local - yes
-- Checking if compiler supports needed C++17 constructs
-- Checking if compiler supports needed C++17 constructs - yes
-- Checking if compiler supports C++ make_unique
-- Checking if compiler supports C++ make_unique - no
-- Checking if compiler supports C++ unique_ptr
-- Checking if compiler supports C++ unique_ptr - no
CMake Error at CMakeLists.txt:92 (message):
The C++ compiler does not support C++11 (e.g. std::unique_ptr).
-- Configuring incomplete, errors occurred!
See also "/home/max/Lavori/nova/src/repos/dep-startup/buildroot-output/buildroot-2020.02.1/output/build/host-cmake-3.15.5/CMakeFiles/CMakeOutput.log".
See also "/home/max/Lavori/nova/src/repos/dep-startup/buildroot-output/buildroot-2020.02.1/output/build/host-cmake-3.15.5/CMakeFiles/CMakeError.log".
---------------------------------------------
Error when bootstrapping CMake:
Problem while running initial CMake
I am absolutely sure that g++ 9.3.0 supports C++11, so where could the problem be?
(EDIT: added CMakeError.log)
Here is the CMakeError.log file:
Determining if compiler supports C++ make_unique failed with the following output:
Change Dir: /home/max/Lavori/nova/srcs/repo/dep-startup/buildroot-output/buildroot-2020.02.1/output/build/host-cmake-3.15.5/CMakeFiles/CMakeTmp
Run Build Command(s):/usr/bin/make cmTC_f5a77/fast && make[2]: Entering directory '/home/max/Lavori/nova/srcs/repo/dep-startup/buildroot-output/buildroot-2020.02.1/output/build/host-cmake-3.15.5/CMakeFiles/CMakeTmp'
make[2]: Warning: File 'Makefile' has modification time 0,27 s in the future
make -f CMakeFiles/cmTC_f5a77.dir/build.make CMakeFiles/cmTC_f5a77.dir/build
make[3]: Entering directory '/home/max/Lavori/nova/srcs/repo/dep-startup/buildroot-output/buildroot-2020.02.1/output/build/host-cmake-3.15.5/CMakeFiles/CMakeTmp'
make[3]: Warning: File 'CMakeFiles/cmTC_f5a77.dir/flags.make' has modification time 0,26 s in the future
Building CXX object CMakeFiles/cmTC_f5a77.dir/cm_cxx_make_unique.cxx.o
/usr/bin/g++ -O2 -std=gnu++17 -o CMakeFiles/cmTC_f5a77.dir/cm_cxx_make_unique.cxx.o -c /home/max/Lavori/nova/srcs/repo/dep-startup/buildroot-output/buildroot-2020.02.1/output/build/host-cmake-3.15.5/Source/Checks/cm_cxx_make_unique.cxx
Linking CXX executable cmTC_f5a77
/home/max/Lavori/nova/srcs/repo/dep-startup/buildroot-output/buildroot-2020.02.1/output/build/host-cmake-3.15.5/Bootstrap.cmk/cmake -E cmake_link_script CMakeFiles/cmTC_f5a77.dir/link.txt --verbose=1
/usr/bin/g++ -O2 -L/home/max/Lavori/nova/srcs/repo/dep-startup/buildroot-output/buildroot-2020.02.1/output/host/lib -Wl,-rpath,/home/max/Lavori/nova/srcs/repo/dep-startup/buildroot-output/buildroot-2020.02.1/output/host/lib CMakeFiles/cmTC_f5a77.dir/cm_cxx_make_unique.cxx.o -o cmTC_f5a77
make[3]: warning: Clock skew detected. Your build may be incomplete.
make[3]: Leaving directory '/home/max/Lavori/nova/srcs/repo/dep-startup/buildroot-output/buildroot-2020.02.1/output/build/host-cmake-3.15.5/CMakeFiles/CMakeTmp'
make[2]: warning: Clock skew detected. Your build may be incomplete.
make[2]: Leaving directory '/home/max/Lavori/nova/srcs/repo/dep-startup/buildroot-output/buildroot-2020.02.1/output/build/host-cmake-3.15.5/CMakeFiles/CMakeTmp'
Determining if compiler supports C++ unique_ptr failed with the following output:
Change Dir: /home/max/Lavori/nova/srcs/repo/dep-startup/buildroot-output/buildroot-2020.02.1/output/build/host-cmake-3.15.5/CMakeFiles/CMakeTmp
Run Build Command(s):/usr/bin/make cmTC_02c6e/fast && make[2]: Entering directory '/home/max/Lavori/nova/srcs/repo/dep-startup/buildroot-output/buildroot-2020.02.1/output/build/host-cmake-3.15.5/CMakeFiles/CMakeTmp'
make[2]: Warning: File 'Makefile' has modification time 0,27 s in the future
make -f CMakeFiles/cmTC_02c6e.dir/build.make CMakeFiles/cmTC_02c6e.dir/build
make[3]: Entering directory '/home/max/Lavori/nova/srcs/repo/dep-startup/buildroot-output/buildroot-2020.02.1/output/build/host-cmake-3.15.5/CMakeFiles/CMakeTmp'
make[3]: Warning: File 'CMakeFiles/cmTC_02c6e.dir/flags.make' has modification time 0,26 s in the future
Building CXX object CMakeFiles/cmTC_02c6e.dir/cm_cxx_unique_ptr.cxx.o
/usr/bin/g++ -O2 -std=gnu++17 -o CMakeFiles/cmTC_02c6e.dir/cm_cxx_unique_ptr.cxx.o -c /home/max/Lavori/nova/srcs/repo/dep-startup/buildroot-output/buildroot-2020.02.1/output/build/host-cmake-3.15.5/Source/Checks/cm_cxx_unique_ptr.cxx
Linking CXX executable cmTC_02c6e
/home/max/Lavori/nova/srcs/repo/dep-startup/buildroot-output/buildroot-2020.02.1/output/build/host-cmake-3.15.5/Bootstrap.cmk/cmake -E cmake_link_script CMakeFiles/cmTC_02c6e.dir/link.txt --verbose=1
/usr/bin/g++ -O2 -L/home/max/Lavori/nova/srcs/repo/dep-startup/buildroot-output/buildroot-2020.02.1/output/host/lib -Wl,-rpath,/home/max/Lavori/nova/srcs/repo/dep-startup/buildroot-output/buildroot-2020.02.1/output/host/lib CMakeFiles/cmTC_02c6e.dir/cm_cxx_unique_ptr.cxx.o -o cmTC_02c6e
make[3]: warning: Clock skew detected. Your build may be incomplete.
make[3]: Leaving directory '/home/max/Lavori/nova/srcs/repo/dep-startup/buildroot-output/buildroot-2020.02.1/output/build/host-cmake-3.15.5/CMakeFiles/CMakeTmp'
make[2]: warning: Clock skew detected. Your build may be incomplete.
make[2]: Leaving directory '/home/max/Lavori/nova/srcs/repo/dep-startup/buildroot-output/buildroot-2020.02.1/output/build/host-cmake-3.15.5/CMakeFiles/CMakeTmp'
I cannot figure out wath is wrong.
I thought it could be a clock skew problem but I tried also outside a virtual machine with identical results.
I also tried to compile and link by hand without any errors or warnings.
/usr/bin/g++ -O2 -std=gnu++17 -o cm_cxx_make_unique.cxx.o -c /home/max/Lavori/nova/srcs/repo/dep-startup/buildroot-output/buildroot-2020.02.1/output/build/host-cmake-3.15.5/Source/Checks/cm_cxx_make_unique.cxx
/usr/bin/g++ -O2 -L/home/max/Lavori/nova/srcs/repo/dep-startup/buildroot-output/buildroot-2020.02.1/output/host/lib -Wl,-rpath,/home/max/Lavori/nova/srcs/repo/dep-startup/buildroot-output/buildroot-2020.02.1/output/host/lib cm_cxx_make_unique.cxx.o -o cmTC_f5a77
I also tried to run the binary without errors.
So even more 'I can not figure out what is wrong

Has same error when use Linux virtual machine (VMware) and when sources placed in shared folder. When move sources to user folder all configured successfully.

Related

ERRO Linux Mint "Check for working C compiler: /usr/bin/cc "

i want to use virtual camera on linux with obs studio. i see this package https://github.com/CatxFish/obs-v4l2sink
i ran
sudo apt install qtbase5-dev
sudo apt install libobs-dev
git clone --recursive https://github.com/obsproject/obs-studio.git
git clone https://github.com/CatxFish/obs-v4l2sink.git cd obs-v4l2sink mkdir build && cd build cmake -DLIBOBS_INCLUDE_DIR="../../obs-studio/libobs" -DCMAKE_INSTALL_PREFIX=/usr ..
when i ran cmake -DLIBOBS_INCLUDE_DIR="../../obs-studio/libobs" -DCMAKE_INSTALL_PREFIX=/usr ..
i got error
`-- The C compiler identification is GNU 9.3.0
-- The CXX compiler identification is unknown
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- broken
CMake Error at /usr/share/cmake-3.16/Modules/CMakeTestCCompiler.cmake:60 (message):
The C compiler
"/usr/bin/cc"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: /home/arp/obs-v4l2sink/build/CMakeFiles/CMakeTmp
Run Build Command(s):/usr/bin/make cmTC_a18d3/fast && /usr/bin/make -f CMakeFiles/cmTC_a18d3.dir/build.make CMakeFiles/cmTC_a18d3.dir/build
make[1]: Entering directory '/home/arp/obs-v4l2sink/build/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_a18d3.dir/testCCompiler.c.o
/usr/bin/cc -o CMakeFiles/cmTC_a18d3.dir/testCCompiler.c.o -c /home/arp/obs-v4l2sink/build/CMakeFiles/CMakeTmp/testCCompiler.c
Linking C executable cmTC_a18d3
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_a18d3.dir/link.txt --verbose=1
/usr/bin/cc CMakeFiles/cmTC_a18d3.dir/testCCompiler.c.o -o cmTC_a18d3
/usr/bin/ld: cannot find Scrt1.o: No such file or directory
/usr/bin/ld: cannot find crti.o: No such file or directory
collect2: error: ld returned 1 exit status
make[1]: *** [CMakeFiles/cmTC_a18d3.dir/build.make:87: cmTC_a18d3] Error 1
make[1]: Leaving directory '/home/arp/obs-v4l2sink/build/CMakeFiles/CMakeTmp'
make: *** [Makefile:121: cmTC_a18d3/fast] Error 2
CMake will not be able to correctly generate this project. Call Stack (most recent call first): CMakeLists.txt:2 (project)
CMake Error at CMakeLists.txt:2 (project): No CMAKE_CXX_COMPILER could be found.
Tell CMake where to find the compiler by setting either the environment variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path to the compiler, or to the compiler name if it is in the PATH.
-- Configuring incomplete, errors occurred! See also "/home/arp/obs-v4l2sink/build/CMakeFiles/CMakeOutput.log". See also "/home/arp/obs-v4l2sink/build/CMakeFiles/CMakeError.log".
i have seen some articles. but nothing changes.
anyone can help me?

CMake: find_library result depends on selected compiler?

I'm confused about how find_library is supposed to work, and I don't know if this could be a CMake bug, or a misuse or misconfiguration on my part. I have installed both GCC and PGI compilers, and when I try this simple CMakeLists.txt file (with both 2.8.11 and 3.5.1):
cmake_minimum_required(VERSION 2.8.11)
find_library( LIBdl dl )
message("LIBdl ${LIBdl}")
I get the following:
$ CC=gcc CXX=g++ cmake .
-- The C compiler identification is GNU 4.8.4
-- The CXX compiler identification is GNU 4.8.4
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/g++
-- Check for working CXX compiler: /usr/bin/g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
LIBdl /usr/lib/x86_64-linux-gnu/libdl.so
-- Configuring done
-- Generating done
-- Build files have been written to: /home/molcas-test/test/cmake
That's OK, but:
$ CC=pgcc CXX=pgc++ cmake .
-- The C compiler identification is PGI 17.1.0
-- The CXX compiler identification is PGI 17.1.0
-- Check for working C compiler: /opt/pgi/linux86-64/17.1/bin/pgcc
-- Check for working C compiler: /opt/pgi/linux86-64/17.1/bin/pgcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /opt/pgi/linux86-64/17.1/bin/pgc++
-- Check for working CXX compiler: /opt/pgi/linux86-64/17.1/bin/pgc++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
LIBdl LIBdl-NOTFOUND
-- Configuring done
-- Generating done
-- Build files have been written to: /home/molcas-test/test/cmake
Note dl was not found.
Leaving out either pgcc or pgc++ causes the library to be found, so it must be something in how the compilers are configured. And yet just compiling from the command line finds dl without complain:
$ pgcc -ldl hello_world.c -o hello_world
$ ./hello_world
Hello world!
So I believe something's not right if pgcc can find the library and CMake can't. I could of course set LIB=/usr/lib/x86_64-linux-gnu before running cmake, to force a search in that directory, but that doesn't feel right.
It seems the problem is with gcc. I get /lib/x86_64-linux-gnu included in CMAKE_C_IMPLICIT_LINK_DIRECTORIES, so CMAKE_LIBRARY_ARCHITECTURE is set. But with pgcc this directory is absent and CMAKE_LIBRARY_ARCHITECTURE is empty.
And the directory is missing with pgcc, because pgcc -v doesn't include a -L/lib/x86_64-linux-gnu flag, while gcc -v does. However, ld finds libraries in the directory in either case.
So CMake is not searching libraries in the same places as ld. Should it? Is there an easy way to change this, other than, e.g., manually inspecting all files in /etc/ld.so.conf.d and setting the LIB environment variable?

Compiling OpenVAS-SMB on Debian Stretch

I'm trying to build the OpenVAS-SMB plugin on Debian Stretch from source, but it fails, although it builds successfully with the same prerequisites on Debian Jessie.
CMake confirms all required dependencies before starting to build:
root#xxxx:/home/xxxx/openvas-smb-1.0.2# cmake . && make
-- The C compiler identification is GNU 6.3.0
-- The CXX compiler identification is GNU 6.3.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Perl: /usr/bin/perl (found version "5.24.1")
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29")
-- Checking for module 'popt'
-- Found popt, version 1.16
-- Found Popt: /usr/lib/x86_64-linux-gnu/libpopt.so
-- Found GSSAPI: /usr/lib/x86_64-linux-gnu/libcom_err.so
-- Install prefix: /usr/local
-- Checking for module 'gnutls>=3.2.15'
-- Found gnutls, version 3.5.8
-- Checking for module 'glib-2.0'
-- Found glib-2.0, version 2.50.3
-- Found GnuTLS: /usr/lib/x86_64-linux-gnu/libgnutls.so (found version "3.5.8")
-- Looking for xmltoman...
-- Looking for xmltoman... /usr/bin/xmltoman
-- Looking for xmlmantohtml... /usr/bin/xmlmantohtml
-- Found Doxygen: /usr/bin/doxygen (found version "1.8.13")
-- Configuring done
-- Generating done
It builds samba and the libs correctly, but fails when it comes to winexe:
../samba/libsamba-static.a(kerberos.c.o): In function `kerberos_kinit_password_cc':
kerberos.c:(.text+0x124): undefined reference to `krb5_get_init_creds_opt_init'
kerberos.c:(.text+0x133): undefined reference to `krb5_get_init_creds_opt_set_default_flags'
kerberos.c:(.text+0x153): undefined reference to `krb5_get_init_creds_password'
kerberos.c:(.text+0x182): undefined reference to `krb5_cc_initialize'
kerberos.c:(.text+0x196): undefined reference to `krb5_cc_store_cred'
kerberos.c:(.text+0x1d2): undefined reference to `krb5_free_cred_contents'
kerberos.c:(.text+0x1e7): undefined reference to `krb5_free_cred_contents'
collect2: error: ld returned 1 exit status
winexe/CMakeFiles/winexe.dir/build.make:186: recipe for target 'winexe/winexe' failed
make[2]: *** [winexe/winexe] Error 1
CMakeFiles/Makefile2:145: recipe for target 'winexe/CMakeFiles/winexe.dir/all' failed
make[1]: *** [winexe/CMakeFiles/winexe.dir/all] Error 2
Makefile:149: recipe for target 'all' failed
make: *** [all] Error 2
I'm guessing that there's an issue with either heimdal-dev or the libglib2.0-dev causing this.
These are the requirements for building OpenVAS-SMB besides the typical build tools: gcc-mingw-w64 libgnutls28-dev perl-base heimdal-dev heimdal-multidev libpopt-dev libglib2.0-dev
Anyone know of any differences between the libs that could make the build fail on Stretch, but work on Jessie? Or maybe can provide a hint on how to do further troubleshooting?
Thanks!

cmake in cygwin: cyglto_plugin.dll not found

I am trying to get a Fortran 90 program to compile under Windows. I have already successfully done so under Linux.
I am using the 'Babun' windows shell, which is basically a wrapper for cygwin: https://github.com/babun/babun
When I try and run cmake, I get the following:
-- The Fortran compiler identification is GNU
-- Check for working Fortran compiler: /usr/bin/gfortran.exe
-- Check for working Fortran compiler: /usr/bin/gfortran.exe -- broken
CMake Error at /usr/share/cmake-2.8.9/Modules/CMakeTestFortranCompiler.cmake:40 (MESSAGE):
The Fortran compiler "/usr/bin/gfortran.exe" is not able to compile a
simple test program.
It fails with the following output:
Change Dir: /cygdrive/d/Users/bob/code/vasa/build/CMakeFiles/CMakeTmp
Run Build Command:/usr/bin/make.exe "cmTryCompileExec674739544/fast"
/usr/bin/make -f CMakeFiles/cmTryCompileExec674739544.dir/build.make
CMakeFiles/cmTryCompileExec674739544.dir/build
make[1]: Entering directory
'/cygdrive/d/Users/bob/code/vasa/build/CMakeFiles/CMakeTmp'
/usr/bin/cmake.exe -E cmake_progress_report
/cygdrive/d/Users/bob/code/vasa/build/CMakeFiles/CMakeTmp/CMakeFiles
1
Building Fortran object
CMakeFiles/cmTryCompileExec674739544.dir/testFortranCompiler.f.o
/usr/bin/gfortran.exe -c
/cygdrive/d/Users/bob/code/vasa/build/CMakeFiles/CMakeTmp/testFortranCompiler.f
-o CMakeFiles/cmTryCompileExec674739544.dir/testFortranCompiler.f.o
Linking Fortran executable cmTryCompileExec674739544.exe
/usr/bin/cmake.exe -E cmake_link_script
CMakeFiles/cmTryCompileExec674739544.dir/link.txt --verbose=1
/usr/bin/gfortran.exe -Wl,--enable-auto-import
CMakeFiles/cmTryCompileExec674739544.dir/testFortranCompiler.f.o -o
cmTryCompileExec674739544.exe
-Wl,--out-implib,libcmTryCompileExec674739544.dll.a
-Wl,--major-image-version,0,--minor-image-version,0
gfortran: fatal error: -fuse-linker-plugin, but cyglto_plugin.dll not found
compilation terminated.
CMakeFiles/cmTryCompileExec674739544.dir/build.make:83: recipe for target
'cmTryCompileExec674739544.exe' failed
make[1]: *** [cmTryCompileExec674739544.exe] Error 1
make[1]: Leaving directory
'/cygdrive/d/Users/bob/code/vasa/build/CMakeFiles/CMakeTmp'
Makefile:117: recipe for target 'cmTryCompileExec674739544/fast' failed
make: *** [cmTryCompileExec674739544/fast] Error 2
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:9 (enable_language)
What package does this cyglto_plugin.dll belong to? What dependencies am I missing?
Thanks!

How to fix error: bad value (native) for -march= switch and -mtune= switch?

I am compiling the library provided here: http://www.robots.ox.ac.uk/~vgg/software/fastann/, but
bash-3.2$ PREFIX=/usr/local/ cmake . && make
-- The C compiler identification is GNU
-- The CXX compiler identification is GNU
-Wall -O2 -g3 -msse2 -march=native -fno-exceptions -fno-rtti
--- Prefix = /usr/local/
-- Configuring done
-- Generating done
-- Build files have been written to: /path/to/dir
[ 14%] Building CXX object CMakeFiles/fastann.dir/dist_l2.cpp.o
/path/to/dir/dist_l2.cpp:1: error: bad value (native) for -march= switch
/path/to/dir/dist_l2.cpp:1: error: bad value (native) for -mtune= switch
make[2]: *** [CMakeFiles/fastann.dir/dist_l2.cpp.o] Error 1
make[1]: *** [CMakeFiles/fastann.dir/all] Error 2
make: *** [all] Error 2
bash-3.2$
This is only the first step in the provided instruction, and I don't know where to look next. Can somebody tell me what exactly is this error, and how to fix it?
How to fix error: bad value (native) for -march= switch and -mtune= switch?
The problem is with -march=nartive. According to Ian Lance Taylor on GCC's mailing list (Ian is one of the GCC devs):
The problem is that the driver code is not working, and the bug is
that gcc doesn't handle that [-march=native] correctly. There is some code in gcc to
handle the driver code failing, and it works for -mtune=native, but
not for -march=native.
The driver code is supposed to change the -march=native to be
-march=XXX for your CPU. The code is in
gcc/config/i386/driver-i386.c.
So the workaround is to avoid using -march=native; and use either (1) -m32 or -m64, or (2) use -march=cpu-type, where cpu-type is one of the ones listed at 3.17.15 Intel 386 and AMD x86-64 Options of the GCC manual. The list is extensive, and it includes pentium, pentium2, pentium3 and pentium4.
Switch to using a version of gcc equal or larger then 4.2.
gcc's version 4.2 introduced the native march.
Use
gcc --version
to get gcc's version information.

Resources