build kernel module - Linux

By Gary
at 2014-04-02T19:54
at 2014-04-02T19:54
Table of Contents
在進行android embedded system開發時
遇到了kernel module編譯的小問題, 還請各位指教, 謝謝!
Q1 :
假如我只想要單build kernel module ,
我需要完整的kernel source tree嗎?
還是只需要kernel source 的 header file package?
A1 :
有些部落格提到是下載整個kernel source tree,
然後還要把這個kernel source tree給build過一次 ...
可是我從國外網站查到的答案如下,
簡單來說就是不需要kernel source tree, 只需要kernel headers
請問各位是如何處理的呢 @@?
ref - http://ppt.cc/Tl91
In order to build a kernel module, we need the kernel headers
(or kernel source) that match the binary image.
The headers provide vital definitions that are needed
in order to compile the source code for the module.
The compressed source code is about 110MBytes in size.
This is the full source for the kernel including all of the headers.
Strictly speaking, we just need the headers, but you might want to
explore the kernel, other kernel modules, ARM-specific support code,
or the PERF subsystem. It’s all there.
ref - http://ppt.cc/Fuy8
To be frank you do not need a new full source tree in order to
just compile or build module against the running kernel
i.e an exploded source tree is not required to build kernel driver or module.
Please note that to work with this hack you just need the Linux kernel
headers
and not the full kernel source tree.
也就是說
通常下載的 kernel source code 會在 /usr/src/linux-xxx
/lib/modules/3.6.11+/build 這邊的build 會 ln 到 上面的位址
如果沒有 就手動建立link
ln -s /usr/src/linux /lib/modules/3.6.11+/build
note.
上面那個build你可以連到 kernel source header only
或 kernel full source
================================================================================
Q2.
一般我們build一個c程式, 在link 其他 library 時有兩種case:
a. standard c library , 這不需要特別指定路徑,
gcc 會去 /usr/include 找header ,
去 /usr/lib 找 libc.a libc.so
b. 3rd party library, 這就要指定
header file 及 library binary(*.a / *.so) 的位置
然而在build kernel module的時候,
怎沒看到需要去指定library的動作呢 ?
我的意思是, 自訂的 kernel module 中會include 到
platform.h init.h 之類非standard c 的 部份 ,
這些部份在build kernel module的時候是如何處理的?
文長請多包含 謝謝!
--
遇到了kernel module編譯的小問題, 還請各位指教, 謝謝!
Q1 :
假如我只想要單build kernel module ,
我需要完整的kernel source tree嗎?
還是只需要kernel source 的 header file package?
A1 :
有些部落格提到是下載整個kernel source tree,
然後還要把這個kernel source tree給build過一次 ...
可是我從國外網站查到的答案如下,
簡單來說就是不需要kernel source tree, 只需要kernel headers
請問各位是如何處理的呢 @@?
ref - http://ppt.cc/Tl91
In order to build a kernel module, we need the kernel headers
(or kernel source) that match the binary image.
The headers provide vital definitions that are needed
in order to compile the source code for the module.
The compressed source code is about 110MBytes in size.
This is the full source for the kernel including all of the headers.
Strictly speaking, we just need the headers, but you might want to
explore the kernel, other kernel modules, ARM-specific support code,
or the PERF subsystem. It’s all there.
ref - http://ppt.cc/Fuy8
To be frank you do not need a new full source tree in order to
just compile or build module against the running kernel
i.e an exploded source tree is not required to build kernel driver or module.
Please note that to work with this hack you just need the Linux kernel
headers
and not the full kernel source tree.
也就是說
通常下載的 kernel source code 會在 /usr/src/linux-xxx
/lib/modules/3.6.11+/build 這邊的build 會 ln 到 上面的位址
如果沒有 就手動建立link
ln -s /usr/src/linux /lib/modules/3.6.11+/build
note.
上面那個build你可以連到 kernel source header only
或 kernel full source
================================================================================
Q2.
一般我們build一個c程式, 在link 其他 library 時有兩種case:
a. standard c library , 這不需要特別指定路徑,
gcc 會去 /usr/include 找header ,
去 /usr/lib 找 libc.a libc.so
b. 3rd party library, 這就要指定
header file 及 library binary(*.a / *.so) 的位置
然而在build kernel module的時候,
怎沒看到需要去指定library的動作呢 ?
我的意思是, 自訂的 kernel module 中會include 到
platform.h init.h 之類非standard c 的 部份 ,
這些部份在build kernel module的時候是如何處理的?
文長請多包含 謝謝!
--
Tags:
Linux
All Comments

By Daniel
at 2014-04-03T00:42
at 2014-04-03T00:42
Related Posts
找不到HP ML110 G5 centos的RAID驅動...

By Christine
at 2014-04-01T16:37
at 2014-04-01T16:37
Cent OS網路問題

By Faithe
at 2014-03-31T22:36
at 2014-03-31T22:36
如何讓電腦架設可讓外界使用的SSH連線

By Isla
at 2014-03-31T22:11
at 2014-03-31T22:11
RedHat次版本的差異性

By Ophelia
at 2014-03-31T19:58
at 2014-03-31T19:58
git 列出某的版本號之後所有異動過的檔案

By Elizabeth
at 2014-03-31T17:33
at 2014-03-31T17:33