fatal error: linux/compiler-gcc9.h: No such file or directory

linux

找到README文件

复制代码
cd /mnt/e/CLionProjects/linux-3.10.99/linux-3.10.99
sudo useradd linux3x
sudo passwd linux3x
sudo mkdir /home/linux3x
sudo chown linux3x:linu3x /home/linux3x
sudo chmod 755 /home/linux3x
su - linux3x
mkdir ~/build
mkdir ~/build/kernel
exit
make O=/home/linux3x/build/kernel menuconfig
make O=/home/linux3x/build/kernel
# sudo make O=/home/linux3x/build/kernel modules_install install

mzh@DESKTOP-GITL67P:~$ gcc --version

gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0

Copyright (C) 2019 Free Software Foundation, Inc.

This is free software; see the source for copying conditions. There is NO

warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

因为当前gcc版本是9.x, 找不到 compiler-gcc9.h, 复制compiler-gcc5.h成compiler-gcc9.h

Kernel doesn't support PIC mode for compiling?

bash 复制代码
# force no-pie for distro compilers that enable pie by default
KBUILD_CFLAGS += $(call cc-option, -fno-pie)
KBUILD_CFLAGS += $(call cc-option, -no-pie)
KBUILD_AFLAGS += $(call cc-option, -fno-pie)
KBUILD_CPPFLAGS += $(call cc-option, -fno-pie)

cp E:\CLionProjects\linux-3.10.99\linux-3.10.99\include\linux\compiler-gcc5.h E:\CLionProjects\linux-3.10.99\linux-3.10.99\include\linux\compiler-gcc9.h

CLion头文件报错

标红,不能跳转

sudo cp -r ./include/linux/ /usr/local/include/

不要copy到/usr/include, 否则当前运行的操作系统坏了。

mzh@DESKTOP-GITL67P:/mnt/e/CLionProjects/linux-3.10.99/linux-3.10.99$ sudo rsync -avz ./include/ /usr/local/include/

但是这样会重复定义,所以还是用vim算了。

mzh@DESKTOP-GITL67P:/usr/local/include$ rm -rf acpi/ asm-generic/ clocksource/ config/ crypto/ drm/ dt-bindings/ generated/ keys/ linux3x/ math-emu/ media/ memory/ misc/ net/ pcmcia/ ras/ rdma/ rxrpc/ scsi/ sound/ target/ trace/ uapi/ video/ xen/

sudo apt-get install ctags

$ cat tags.sh

bash 复制代码
#/bin/bash

WORKDIR="/mnt/e/CLionProjects/linux-3.10.99/linux-3.10.99"
find "${WORKDIR}" -name "*.[c|h]" | xargs ctags -f "${WORKDIR}/tags"
find /usr/include -name "*.h" | xargs ctags -a "${WORKDIR}/tags"

ctags -a 表示追加索引内容到tags文件。Linux不依赖libc.so,所以不需要添加/usr/include。

./tags.sh

在~/.vimrc中添加

set tags="/mnt/e/CLionProjects/linux-3.10.99/linux-3.10.99/tags"

对于报错Time skewed

sudo ntpdate -uv time.windows.com

相关推荐
上海云盾-小余4 分钟前
DDoS 攻击应急响应全流程:从告警触发到业务恢复的黄金 15 分钟
服务器·安全·游戏·ddos
LXY_BUAA8 分钟前
《ubuntu22.04》_新系统的配置_20260418
linux·运维·服务器
上海云盾-小余8 分钟前
API 接口 DDoS 与 CC 攻击防护实战:守住业务最脆弱的数字入口
服务器·ddos
楼田莉子12 分钟前
同步/异步日志系统:日志落地模块\日志器模块\异步日志模块
linux·服务器·c++·学习·设计模式
洛水水1 小时前
图解式讲解内存池:告别内存碎片与随机coredump
linux·内存池
NightReader1 小时前
SSH Client推荐集
运维·ssh
小章UPUP2 小时前
2025-2026 新FFmpeg GUI工具推荐
linux
探索宇宙真理.3 小时前
Nginx UI MCP接口绕过认证漏洞 | CVE-2026-33032复现&研究
运维·经验分享·网络安全·nginx-ui
llm大模型算法工程师weng3 小时前
负载均衡做什么?nginx是什么
运维·开发语言·nginx·负载均衡
byoass3 小时前
企业云盘私有化部署:存储架构设计与安全运维全流程实战
运维·网络·安全·云计算