Problem with gcc during install

Dear all,

I wish to install LAMMPS version 3Aug2022 using cmake after updating gcc version 4.8.5 to 11.1 on Centos 7 workstation.
I used gcc install from devtoolset-11 as root superuser. gcc 11 was thus installed for all workstation users.
as user (not root), my cmake command and output were:

cmake -C …/cmake/presets/most.cmake -C …/cmake/presets/kokkos-openmp.cmake -D KOKKOS=yes -D Kokkos_ARCH_SKX=yes -D Kokkos_ENABLE_OPENMP=yes -D BUILD_OMP=yes …/cmake
loading initial cache file …/cmake/presets/most.cmake
loading initial cache file …/cmake/presets/kokkos-openmp.cmake
– The CXX compiler identification is GNU 11.1.0
– Detecting CXX compiler ABI info
– Detecting CXX compiler ABI info - failed
– Check for working CXX compiler: /usr/local/bin/g++
– Check for working CXX compiler: /usr/local/bin/g++ - broken
CMake Error at /usr/local/share/cmake-3.19/Modules/CMakeTestCXXCompiler.cmake:59 (message):
The C++ compiler

"/usr/local/bin/g++"

is not able to compile a simple test program.

It fails with the following output:

Change Dir: /home/pascal/lammps-3Aug2022/build/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/bin/gmake cmTC_426fa/fast && /usr/bin/gmake  -f CMakeFiles/cmTC_426fa.dir/build.make CMakeFiles/cmTC_426fa.dir/build
gmake[1]: Entering directory `/home/pascal/lammps-3Aug2022/build/CMakeFiles/CMakeTmp'
Building CXX object CMakeFiles/cmTC_426fa.dir/testCXXCompiler.cxx.o
/usr/local/bin/g++    -o CMakeFiles/cmTC_426fa.dir/testCXXCompiler.cxx.o -c /home/pascal/lammps-3Aug2022/build/CMakeFiles/CMakeTmp/testCXXCompiler.cxx
Linking CXX executable cmTC_426fa
/usr/local/bin/cmake -E cmake_link_script CMakeFiles/cmTC_426fa.dir/link.txt --verbose=1
/usr/local/bin/g++ CMakeFiles/cmTC_426fa.dir/testCXXCompiler.cxx.o -o cmTC_426fa 
/usr/bin/ld: cannot find crtbegin.o: No such file or directory
/usr/bin/ld: cannot find -lstdc++
/usr/bin/ld: cannot find -lgcc_s
/usr/bin/ld: cannot find -lgcc
collect2: error: ld returned 1 exit status
gmake[1]: *** [cmTC_426fa] Error 1
gmake[1]: Leaving directory `/home/pascal/lammps-3Aug2022/build/CMakeFiles/CMakeTmp'
gmake: *** [cmTC_426fa/fast] Error 2

CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:17 (project)

– Configuring incomplete, errors occurred!
See also “/home/pascal/lammps-3Aug2022/build/CMakeFiles/CMakeOutput.log”.
See also “/home/pascal/lammps-3Aug2022/build/CMakeFiles/CMakeError.log”.

It seems there is a gcc install mistake but I do not see which one.
Thanks a lot for help
Best
Pascal

These error messages are an indicator of a serious problem. The compiler at that step is passing information to the linker to construct the executable and that needs files that are specific to the compiler. However, those files are not found. That usually means the compiler was compiled to be located in a specific directory tree and is now elsewhere and thus any compiled in or configured in paths are no longer valid.

You could try to confirm this by compiling a simple C++ program with the custom compiler like this:
g++ -v hello.cpp
and you will get an output for the linker step at the end like this:

COMPILER_PATH=/usr/libexec/gcc/x86_64-redhat-linux/12/:/usr/libexec/gcc/x86_64-redhat-linux/12/:/usr/libexec/gcc/x86_64-redhat-linux/:/usr/lib/gcc/x86_64-redhat-linux/12/:/usr/lib/gcc/x86_64-redhat-linux/
LIBRARY_PATH=/usr/lib/gcc/x86_64-redhat-linux/12/:/usr/lib/gcc/x86_64-redhat-linux/12/../../../../lib64/:/lib/../lib64/:/usr/lib/../lib64/:/usr/lib/gcc/x86_64-redhat-linux/12/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-shared-libgcc' '-mtune=generic' '-march=x86-64' '-dumpdir' 'a.'
 /usr/libexec/gcc/x86_64-redhat-linux/12/collect2 -plugin /usr/libexec/gcc/x86_64-redhat-linux/12/liblto_plugin.so -plugin-opt=/usr/libexec/gcc/x86_64-redhat-linux/12/lto-wrapper -plugin-opt=-fresolution=/tmp/ccihAdIQ.res -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc --build-id --no-add-needed --eh-frame-hdr --hash-style=gnu -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 /usr/lib/gcc/x86_64-redhat-linux/12/../../../../lib64/crt1.o /usr/lib/gcc/x86_64-redhat-linux/12/../../../../lib64/crti.o /usr/lib/gcc/x86_64-redhat-linux/12/crtbegin.o -L/usr/lib/gcc/x86_64-redhat-linux/12 -L/usr/lib/gcc/x86_64-redhat-linux/12/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib/gcc/x86_64-redhat-linux/12/../../.. /tmp/ccfZ8CP0.o -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/lib/gcc/x86_64-redhat-linux/12/crtend.o /usr/lib/gcc/x86_64-redhat-linux/12/../../../../lib64/crtn.o
COLLECT_GCC_OPTIONS='-v' '-shared-libgcc' '-mtune=generic' '-march=x86-64' '-dumpdir' 'a.'

Notice all the paths that include /usr/lib/gcc/x86_64-redhat-linux/12? That is where the “missing” compiler specific files are located.

If you do the same, you can compare what your g++ binary expects with what you have on your system.

Hello @pascalbrault,

These looks more like a CentOS specific issue than Cmake. Taking a look at the doc on how to use the gcc compiler installed with devtoolset, I see that you need to give it a prefix command scl enable devtoolset-11. I guess this is because CentOS uses software collections packaging (scl) to avoid conflicts with system files and this might explain the missing files error messages that @akohlmey noticed.

You can find a comment to a similar question here. This is a problem similar to the module loading in other distribution like fedora.

1 Like

Hello @akohlmey @Germain
Thanks a lot for your answers.
I used the command

scl enable devtoolset-11 bash

It seems it is not permanent. I should to include it in .bash_profile.
I will try further.
Thanks a lot again.
Pascal

dear @akohlmey
I followed your suggestion and run,
[[email protected] ~] scl enable devtoolset-11 bash [[email protected] ~] g++ -v hello.cpp
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/opt/rh/devtoolset-11/root/usr/libexec/gcc/x86_64-redhat-linux/11/lto-wrapper
Target: x86_64-redhat-linux
Configured with: …/configure --enable-bootstrap --enable-languages=c,c++,fortran,lto --prefix=/opt/rh/devtoolset-11/root/usr --mandir=/opt/rh/devtoolset-11/root/usr/share/man --infodir=/opt/rh/devtoolset-11/root/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --with-linker-hash-style=gnu --with-default-libstdcxx-abi=gcc4-compatible --enable-plugin --enable-initfini-array --with-isl=/builddir/build/BUILD/gcc-11.2.1-20220127/obj-x86_64-redhat-linux/isl-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 11.2.1 20220127 (Red Hat 11.2.1-9) (GCC)
COLLECT_GCC_OPTIONS=‘-v’ ‘-shared-libgcc’ ‘-mtune=generic’ ‘-march=x86-64’ ‘-dumpdir’ ‘a-’
/opt/rh/devtoolset-11/root/usr/libexec/gcc/x86_64-redhat-linux/11/cc1plus -quiet -v -D_GNU_SOURCE hello.cpp -quiet -dumpdir a- -dumpbase hello.cpp -dumpbase-ext .cpp -mtune=generic -march=x86-64 -version -o /tmp/cce6athl.s
GNU C++17 (GCC) version 11.2.1 20220127 (Red Hat 11.2.1-9) (x86_64-redhat-linux)
compiled by GNU C version 11.2.1 20220127 (Red Hat 11.2.1-9), GMP version 6.0.0, MPFR version 3.1.1, MPC version 1.0.1, isl version isl-0.18-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory “/opt/rh/devtoolset-11/root/usr/lib/gcc/x86_64-redhat-linux/11/include-fixed”
ignoring nonexistent directory “/opt/rh/devtoolset-11/root/usr/lib/gcc/x86_64-redhat-linux/11/…/…/…/…/x86_64-redhat-linux/include”
#include “…” search starts here:
#include <…> search starts here:
/opt/rh/devtoolset-11/root/usr/lib/gcc/x86_64-redhat-linux/11/…/…/…/…/include/c++/11
/opt/rh/devtoolset-11/root/usr/lib/gcc/x86_64-redhat-linux/11/…/…/…/…/include/c++/11/x86_64-redhat-linux
/opt/rh/devtoolset-11/root/usr/lib/gcc/x86_64-redhat-linux/11/…/…/…/…/include/c++/11/backward
/opt/rh/devtoolset-11/root/usr/lib/gcc/x86_64-redhat-linux/11/include
/usr/local/include
/opt/rh/devtoolset-11/root/usr/include
/usr/include
End of search list.
GNU C++17 (GCC) version 11.2.1 20220127 (Red Hat 11.2.1-9) (x86_64-redhat-linux)
compiled by GNU C version 11.2.1 20220127 (Red Hat 11.2.1-9), GMP version 6.0.0, MPFR version 3.1.1, MPC version 1.0.1, isl version isl-0.18-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 941d26b9f0d81579d00764e7049e53f1
COLLECT_GCC_OPTIONS=‘-v’ ‘-shared-libgcc’ ‘-mtune=generic’ ‘-march=x86-64’ ‘-dumpdir’ ‘a-’
/opt/rh/devtoolset-11/root/usr/libexec/gcc/x86_64-redhat-linux/11/as -v --64 -o /tmp/cci7N0pl.o /tmp/cce6athl.s
GNU assembler version 2.36.1 (x86_64-redhat-linux) using BFD version version 2.36.1-1.el7.2
COMPILER_PATH=/opt/rh/devtoolset-11/root/usr/libexec/gcc/x86_64-redhat-linux/11/:/opt/rh/devtoolset-11/root/usr/libexec/gcc/x86_64-redhat-linux/11/:/opt/rh/devtoolset-11/root/usr/libexec/gcc/x86_64-redhat-linux/:/opt/rh/devtoolset-11/root/usr/lib/gcc/x86_64-redhat-linux/11/:/opt/rh/devtoolset-11/root/usr/lib/gcc/x86_64-redhat-linux/
LIBRARY_PATH=/opt/rh/devtoolset-11/root/usr/lib/gcc/x86_64-redhat-linux/11/:/opt/rh/devtoolset-11/root/usr/lib/gcc/x86_64-redhat-linux/11/…/…/…/…/lib64/:/lib/…/lib64/:/usr/lib/…/lib64/:/opt/rh/devtoolset-11/root/usr/lib/gcc/x86_64-redhat-linux/11/…/…/…/:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS=‘-v’ ‘-shared-libgcc’ ‘-mtune=generic’ ‘-march=x86-64’ ‘-dumpdir’ ‘a.’
/opt/rh/devtoolset-11/root/usr/libexec/gcc/x86_64-redhat-linux/11/collect2 -plugin /opt/rh/devtoolset-11/root/usr/libexec/gcc/x86_64-redhat-linux/11/liblto_plugin.so -plugin-opt=/opt/rh/devtoolset-11/root/usr/libexec/gcc/x86_64-redhat-linux/11/lto-wrapper -plugin-opt=-fresolution=/tmp/ccWhoTAl.res -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc --build-id --no-add-needed --eh-frame-hdr --hash-style=gnu -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 /lib/…/lib64/crt1.o /lib/…/lib64/crti.o /opt/rh/devtoolset-11/root/usr/lib/gcc/x86_64-redhat-linux/11/crtbegin.o -L/opt/rh/devtoolset-11/root/usr/lib/gcc/x86_64-redhat-linux/11 -L/opt/rh/devtoolset-11/root/usr/lib/gcc/x86_64-redhat-linux/11/…/…/…/…/lib64 -L/lib/…/lib64 -L/usr/lib/…/lib64 -L/opt/rh/devtoolset-11/root/usr/lib/gcc/x86_64-redhat-linux/11/…/…/… /tmp/cci7N0pl.o -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /opt/rh/devtoolset-11/root/usr/lib/gcc/x86_64-redhat-linux/11/crtend.o /lib/…/lib64/crtn.o
COLLECT_GCC_OPTIONS=‘-v’ ‘-shared-libgcc’ ‘-mtune=generic’ ‘-march=x86-64’ ‘-dumpdir’ ‘a.’

All works nice now with activating
scl devtoolset-11 bash
best
Pascal