While I was trying to install Virtual Box's Guest Additions, my Ubuntu's screen has been glitching, so I got 2 things to solve, but to no avail.
I read and applied from 3 "askubuntu" posts, the first is "This system is currently not set up to build kernel modules", where I used sudo apt-get install build-essential gcc make perl dkms.
The second is "How do I install kernel header files?". I used both sudo apt-get install linux-headers-generic, and sudo apt-get install linux-headers-$(uname -r).
And the third is "Ubuntu 22.04 default GCC version does not match version that built latest default kernel", where I done sudo apt install --reinstall gcc-12, followed with sudo ln -s -f /usr/bin/gcc-12 /usr/bin/gcc.
So, my current gcc version is now: gcc (12.3.0-1ubuntu1~22.04) 12.3.0
However, I still got the same error when running sudo sh VBoxLinuxAdditions.run.
VirtualBox Guest Additions: Reloading kernel modules and services currently loaded module vboxguest version () does not match to VirtualBox Guest Additions installation version (7.0.8 r156879)
From the /var/log/vboxadd-setup.log
Building the main Guest Additions 7.0.8 module for kernel 6.5.0-35-generic.
Error building the module. Build output follows.
make V=1 CONFIG_MODULE_SIG= CONFIG_MODULE_SIG_ALL= -C /lib/modules/6.5.0-35-generic/build M=/tmp/vbox.0 SRCROOT=/tmp/vbox.0 -j4 modules
make1: warning: -j4 forced in submake: resetting jobserver mode.
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
make -f ./scripts/Makefile.build obj=/tmp/vbox.0 need-builtin=1 need-modorder=1
I think I should done something obvious by now, but I'm too tired and annoyed with this glitches for hours. Thank in advance for anyone pointing out the next obvious step to fix this issue.