Fix Cmake 'Unsupported GNU Version' Error

Page content

While installing the latest beagle-lib according to the LinuxUnstallInstructions, I encountered this error:

#error -- unsupported GNU version! gcc versions later than 11 are not supported! The nvcc flag '-allow-unsupported-compiler' can be used to override this version check; however, using an unsupported host compiler may cause compilation failure or incorrect run time execution. Use at your own risk.

Looking for previous version of gcc

ls /usr/bin/gcc*

If there were previous version gcc installed, it may show:

/usr/bin/gcc-10
/usr/bin/gcc-11
/usr/bin/gcc-12

Also check previous version of g++ by:

ls /usr/bin/g++

/usr/bin/g++-10
/usr/bin/g++-11
/usr/bin/g++-12

Next the gcc-10 and g++-10 would be used.

Install previous version of gcc

If only recent version of gcc installed, it can be installed by:

sudo apt update
sudo apt install gcc-10 g++-10

Make and install with gcc-10

mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX:PATH=$HOME -DCMAKE_C_COMPILER=gcc-10 -DCMAKE_CXX_COMPILER=g++-10 ..
make install

Now there were no error messages.