Code Monkey home page Code Monkey logo

clion-linux-kernel-3.16's Introduction

如何使用clion阅读linux内核代码

欢迎加入qq群:705958262 交流

最直接方式

clone本仓库

git clone https://github.com/nkbai/clion-linux-kernel-3.16.git

或者

git clone https://gitee.com/nkbai/clion-linux-kernel-3.16.git

然后使用clion打开本工程即可.

这个版本针对的是arm处理器,开发板是vexpress-a9

自定义版本

如果你关注的平台不是arm,比如x86,或者不是3.6版本,而是其他版本,那么你就可以自己构造这么一个工程.

1. 正常编译

选个linux平台,比如ubuntu,可以正常编译内核. 然后

make clean
bear make zImage

其中最关键的是bear make zImage,他会在内核源码目录下生成compile_commands.json. 记录完整的编译过程.

2. 生成CMakeLists.txt

这里需要用到工具kernel-grok

sudo apt install ruby
git clone https://github.com/habemus-papadum/kernel-grok.git
cd clion-linux-kernel-3.16
../kernel-grok/generate_cmake

这时候就会生成CMakeLists.txt. 然后打开CMakeLists.txt,添加:

SET(CMAKE_C_COMPILER "gcc")
include_directories(".")
include_directories("./include")

否则会出现头文件找不到的情况.

3. 愉快的阅读源码吧.

其他

这里提供了一个思路,其实所有不支持cmake的传统c/c++项目都可以通过这种方式来导入,至少代码编写,阅读可以流畅许多.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.