Liuw’s Thinkpad

想要赢就先学会输,想要成功就先学会失败

Archive for the ‘build’ tag

Building modules against installed kernel

without comments

I’ve been reading Linux Device Drivers 3rd for quite a long time, and once built a sacrifice system in VMWare. After I upgraded VMWare, the sacrifice kernel hangs, unable to discover root filesystem. It seems to be a driver issue. No matter how I compile my kernel, it hangs at the same place.

I finally give up, I don’t want to waste my time any more. Maybe I should just dump that 2.6.10 and try new ones. No need to

I have a Debian system working as my development system. I just need to install kernel header to get a module building environment.


# apt-get install linux-headers-`uname -r`

When it’s done, build directory should be found in


# ls -d /lib/modules/`uname -r`/build

Here is a handy Makefile for modules.


obj-m += hello.o

all:
        make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules

clean:
        make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean

Written by liuw

七月 16th, 2010 at 11:49 下午

Posted in UNIX-like

Tagged with , , , ,