clion 阅读 linux kernel wsl

早期clion只支持Cmake,Linux源码经bear,kernel-grok生成CmakeList.txt后还要定制一下导入才勉强用

clion 2020.2 支持 Makefile工程一步到位直接导入

https://github.com/microsoft/WSL2-Linux-Kernel

下面 Build Instructions,加上个编译时缺少的 bc

1
2
apt install build-essential flex bison dwarves libssl-dev libelf-dev bc 
make KCONFIG_CONFIG=Microsoft/config-wsl -j$(nproc)

早期会要设置一些如

1
2
3
4
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -nostdinc")
add_definitions(-D__KERNEL__=1)

include/generated/autoconfig.h 手动add_definitions

ref

http://ybin.cc/tools/clion-for-linux-driver-developer/

https://blog.csdn.net/qq_33922306/article/details/120716523

https://kingdo.club/2022/01/06/%E4%BD%BF%E7%94%A8clion-%E9%98%85%E8%AF%BB-%E4%BF%AE%E6%94%B9-%E6%B3%A8%E9%87%8A-linux-%E5%86%85%E6%A0%B8%E6%BA%90%E7%A0%81/