module compilation error

Need help with C, C++, perl, python, etc?

module compilation error

Postby zef » 2007-04-26 15:24


I'm working on re-compiling a driver module for a Elo Touchscreen with following instruction using just the kernel headers:

Howto: build Linux kernel module against installed kernel w/o full kernel source tree

Posted By vivek On September 2, 2006 @ 2:13 am In Linux, FAQ, Howto | 8 Comments

Recently I received a question via email:

How do I build Linux kernel module against installed or running Linux kernel? Do I need to install new kernel source tree from

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. The instruction outlined below will benefit immensely to a developers/power users.

This is essential because if you just want to compile and install driver for new hardware such as Wireless card or SCSI device etc. With following method, you will save the time, as you are not going to compile entire Linux kernel.

Please note that to work with this hack you just need the Linux kernel headers and not the full kernel source tree. Install the linux-kernel-headers package which provides headers from the Linux kernel. These headers are used by the installed headers for GNU glibc and other system libraries as well as compiling modules. Use following command to install kernel headers:
# apt-get install kernel-headers-2.6.xx.xx.xx

Replace xx.xx with your actual running kernel version (e.g. 2.6.8.-2) and architecture name (e.g. 686/em64t/amd64). Use uname -r command to get actual kernel version name. Please note that above command will only install kernel headers and not the entire kernel source-code tree.

All you need to do is change Makefile to use current kernel build directory. You can obtain this directory name by typing following command:
$ ls -d /lib/modules/$(uname -r)/buildOutput:


Let, say you have .c source code file called hello.c. Now create a Makefile as follows in the directory containing hello.c program / file:
$ vi Makefile
Append following text:
obj-m := hello.o
KDIR := /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules

Save and close the file. Type the following command to build the hello.ko module:
$ make

This is the part of main.c source code I'm compiling.
After performing "make" command to start compilation as stated above, I get a two errors on line 53 and 56. So I commented out the lines and compilation finishes without error. Line 53 and 56 is in red. The error was something like getting ")" before the string end ...

// module information
MODULE_AUTHOR("Elo TouchSystems, Inc.");
MODULE_DESCRIPTION("Elo TouchSystems driver module");
MODULE_LICENSE("Elo TouchSystems, Inc., All rights reserved. Copyright(c) 2006");

MODULE_PARM(debug,"i");//(line 53)
MODULE_PARM_DESC(debug, "Debug print for the device" ) ;

MODULE_PARM(elocontrol_major,"i");//(line 56)
MODULE_PARM_DESC(elocontrol_major, "Major Number for the data device" ) ;

The question I have for the experts out there is, can you see what these two lines do? (please let me know if further info is need).
So far driver has no problem for TS, just wanting to makesure.

Thanks in advance to those all!!!

Posts: 15
Joined: 2007-04-21 01:52

Return to Programming

Who is online

Users browsing this forum: No registered users and 6 guests