找到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