Diamorphine
Diamorphine copied to clipboard
Compiling for ubuntu22.04 Linux 6.5.0-35
When compiling for ubuntu22.04 Linux 6.5.0-35 I received a gcc warning about mismatched compilers and an error about an unknown option like so:
warning: the compiler differs from the one used to build the kernel
The kernel was built by: x86_64-linux-gnu-gcc-12 (Ubuntu 12.3.0-1ubuntu1~22.04) 12.3.0
You are using: gcc-12 (Ubuntu 12.3.0-1ubuntu1~22.04) 12.3.0
CC [M] /home/ubuntu/Diamorphine/diamorphine.o
gcc: error: unrecognized command-line option ‘-ftrivial-auto-var-init=zero’
Setting the standard gcc
version to 12 solves it.
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 11
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 12
sudo update-alternatives --config gcc
(select gcc-12 here)
It works.
But I am confused since the error message states that we are already using gcc-12
and we would need to use x86_64-linux-gnu-gcc-12
.
On my system it exists under /usr/bin/x86_64-linux-gnu-gcc-12
thus setting this as the standard gcc
should be the solution.
This is weird.
Anyway maybe the hint that such an error may be resolved by playing around with update-alternatives
is good information.