Для этого теста я следую «Шагу 1» руководства по CMake. Перед запуском я определяю и экспортирую CC=/usr/bin/clang и CXX=/usr/bin/clang++. В результате получается следующий запуск:
Код: Выделить всё
~/tutor/Step1_build$ cmake ../Step1
-- The C compiler identification is Clang 16.0.6
-- The CXX compiler identification is Clang 16.0.6
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/clang - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - failed
-- Check for working CXX compiler: /usr/bin/clang++
-- Check for working CXX compiler: /usr/bin/clang++ - broken
CMake Error at /usr/share/cmake-3.30/Modules/CMakeTestCXXCompiler.cmake:73 (message):
The C++ compiler
"/usr/bin/clang++"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: '/home/buildbot/tutor/Step1_build/CMakeFiles/CMakeScratch/TryCompile-xkFIPT'
Run Build Command(s): /usr/bin/cmake -E env VERBOSE=1 /usr/bin/gmake -f Makefile cmTC_38a55/fast
/usr/bin/gmake -f CMakeFiles/cmTC_38a55.dir/build.make CMakeFiles/cmTC_38a55.dir/build
gmake[1]: Entering directory '/home/buildbot/tutor/Step1_build/CMakeFiles/CMakeScratch/TryCompile-xkFIPT'
Building CXX object CMakeFiles/cmTC_38a55.dir/testCXXCompiler.cxx.o
/usr/bin/clang++ -MD -MT CMakeFiles/cmTC_38a55.dir/testCXXCompiler.cxx.o -MF CMakeFiles/cmTC_38a55.dir/testCXXCompiler.cxx.o.d -o CMakeFiles/cmTC_38a55.dir/testCXXCompiler.cxx.o -c /home/buildbot/tutor/Step1_build/CMakeFiles/CMakeScratch/TryCompile-xkFIPT/testCXXCompiler.cxx
Linking CXX executable cmTC_38a55
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_38a55.dir/link.txt --verbose=1
/usr/bin/clang++ CMakeFiles/cmTC_38a55.dir/testCXXCompiler.cxx.o -o cmTC_38a55
/usr/bin/ld: cannot find -lstdc++: No such file or directory
clang: error: linker command failed with exit code 1 (use -v to see invocation)
gmake[1]: *** [CMakeFiles/cmTC_38a55.dir/build.make:100: cmTC_38a55] Error 1
gmake[1]: Leaving directory '/home/buildbot/tutor/Step1_build/CMakeFiles/CMakeScratch/TryCompile-xkFIPT'
gmake: *** [Makefile:127: cmTC_38a55/fast] Error 2
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:3 (project)
В этом случае я запускал Clang++ 16. Текущее значение по умолчанию для Ubuntu 24.04, похоже, является Clang++ 18. Я тоже это попробовал, но тоже не получилось. ОДНАКО, когда я удаляю CC и CXX и разрешаю использовать GNC G++, это работает:
Код: Выделить всё
~/tutor/Step1_build$ cmake ../Step1
-- The C compiler identification is GNU 13.2.0
-- The CXX compiler identification is GNU 13.2.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done (0.2s)
-- Generating done (0.0s)
-- Build files have been written to: /home/buildbot/tutor/Step1_build
Я мог бы собирать с помощью GCC/G++, но G++ 13.2.0 помечает ошибки, которые не обнаруживались более ранними версиями компилятора. Так что я/мы постараемся со временем это исправить. Но столь впечатляющий сбой Clang++ и CMake стал полной неожиданностью.
- Учебное пособие по CMake: https://cmake.org/cmake/help/latest/guide/ учебник/index.html
- Версия CMake: 3.30.2
- Версия Clang++: 16.0.6 (23ubuntu4)
- Версия Docker: 27.3.1 (в Ubuntu 20.04)
Подробнее здесь: https://stackoverflow.com/questions/791 ... ng-for-cxx