Compiling device drivers with Ubuntu 10.04LTS

Asked by Michel Halde

Hi,

I'm writing a custom device driver, and i would like to know how to build my modularized driver into Ubuntu 10.04LTS Kernel (2.6.32-27).

I've already installed the following directories: /usr/src/linux-headers-2.6.32-27, and /usr/src/linux-headers-2.6.32-27-generic. But no header .h files are there, just Kbuild, Makefile, Kconfig, etc.

Do we have build something to get .h files and objects from the Ubuntu's Kernel ? I need those files (.h and .o) for building my .ko file.

Thanks for your help.

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu linux-meta Edit question
Assignee:
No assignee Edit question
Solved by:
Eliah Kagan
Solved:
Last query:
Last reply:
Revision history for this message
actionparsnip (andrew-woodhead666) said :
#1

Did you install the build-essential package, that usually gives what is needed.

Revision history for this message
Michel Halde (softmike64) said :
#2

I added the build-essential package, but i had no new .h files.

According to this documentation (https://help.ubuntu.com/community/Kernel/Compile), at the section "Reasons for NOT compiling a custom kernel", the first bullet describes exactly my case.

But i don't know which "linux-headers packages" to install...

The packages are already there into a stock ubuntu 10.04LTS desktop ? I have to "make" something under the /usr/src directories ?

Revision history for this message
Best Eliah Kagan (degeneracypressure) said :
#3

You do need to install one of the linux-headers packages, if you don't already have that installed. You should install the one that corresponds to the linux package you have installed.

Open a Terminal window (Applications > Accessories > Terminal), type in the command "uname -r" (without the quotes), and press enter to run it. You should see something like:

2.6.35-25-generic

The part after the numbers indicates which kernel "flavor" you have installed, and that's the linux-headers "flavor" you should install as well. For example, if yours says "generic" like mine does, then you should install linux-headers-generic. If you want to do this from the command-line (i.e. within the Terminal), you can do so with the command:

sudo apt-get install linux-headers-generic

If you installed the package whose name is linux-headers-(version), where (version) is your kernel version, then that's just a virtual package that tells Ubuntu that you have chosen to install and maintain the linux kernel headers manually. You probably don't want that.

Revision history for this message
Michel Halde (softmike64) said :
#4

Thanks Eliah Kagan, that solved my question.