Skip to content

Compiling for ubuntu22.04 Linux 6.5.0-35 #43

@AITleo

Description

@AITleo

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions