Results 1 to 7 of 7
hai friend,
I got the compilation error,when i compile the program,plz tell me how to clear the error....
This is sample device driver program,
test.c
#include <linux/init.h>
#include <linux/module.h>
#include ...
- 03-11-2008 #1Just Joined!
- Join Date
- Feb 2008
- Posts
- 18
how to compile device driver program
hai friend,
I got the compilation error,when i compile the program,plz tell me how to clear the error....
This is sample device driver program,
test.c
#include <linux/init.h>
#include <linux/module.h>
#include <linux/kernel.h>
MODULE_LICENSE("Dual BSD/GPL");
static int hello_init(void) {
printk("<1> Hello world!\n");
return 0;
}
static void hello_exit(void) {
printk("<1> Bye, cruel world\n");
}
module_init(hello_init);
module_exit(hello_exit);
when i compile this, i got the compilation error like this....
gcc -g -D__USE_FIXED_PROTOTYPES__ -o output test.c
test.c:1:24: error: linux/init.h: No such file or directory
test.c:2:26: error: linux/module.h: No such file or directory
test.c:5: error: expected declaration specifiers or ‘...’ before string constant
test.c:5: warning: data definition has no type or storage class
test.c:13: warning: data definition has no type or storage class
test.c:13: warning: parameter names (without types) in function declaration
test.c:14: warning: data definition has no type or storage class
test.c:14: warning: parameter names (without types) in function declaration
make: *** [test] Error 1
I don't know how to clear this....And this is the MAKE file for my program
Makefile..
CC=gcc
CFLAGS=-g -D__USE_FIXED_PROTOTYPES__
#Compiler flags:
# -g -- Enable debugging
# -D__USE_FIXED_PROTOTYPES__
# -- Force the compiler to use the correct headers
# -ansi -- Don't use GNU extensions. Stick to ANSI C.
test: test.c
$(CC) $(CFLAGS) -o output test.c
clean: rm -f output
Plz tell me how to clear the error..
Thanks to all..
Vivek
- 03-11-2008 #2
Do you have glibc-devel and the kernel-headers installed on your system?
- 03-11-2008 #3Just Joined!
- Join Date
- Feb 2008
- Posts
- 18
Hello Daark.Child,
Thanks for replied to my question.....I use ubuntu 7.10. I already installed libc6-dev. I tried to install glibc-devel-2.6-4.i386.rpm. so first i convert .rpm format to .deb format .
then i got this package glibc-devel_2.6-4_i386.deb.
Now i tried to install glibc-devel_2.6-4_i386.deb.But i got the error during installation ..
This is the error,
sundar@ubuntu2:~/Desktop$ sudo dpkg -i glibc-devel_2.6-4_i386.deb
[sudo] password for sundar:
(Reading database ... 138388 files and directories currently installed.)
Unpacking glibc-devel (from glibc-devel_2.6-4_i386.deb) ...
dpkg: error processing glibc-devel_2.6-4_i386.deb (--install):
trying to overwrite `/usr/lib/libieee.a', which is also in package libc6-dev
dpkg-deb: subprocess paste killed by signal (Broken pipe)
Errors were encountered while processing:
glibc-devel_2.6-4_i386.deb
Plz tell me the solution to solve this problem,I am waiting for the reply..
Thanks agian...
vivek
- 03-11-2008 #4
libc6-dev provides the same packages as glibc-devel so there is no need to install it. Try to avoid installing rpm packages on Debian based distros. Check whether you have the kernel source and possibly kernel headers installed. The kernel source should match the version of the kernel you are running.
- 03-12-2008 #5Just Joined!
- Join Date
- Feb 2008
- Posts
- 18
kernel source matches with the kernel
HI Daarkchild
kernel source matches with the kernel, still we are facing same problem, can you give some other program to run, please tell us what are all packages we have to install and how to configure and how to create make file, how to run make file, please explain initial itself
- 03-12-2008 #6Linux Enthusiast
- Join Date
- Aug 2006
- Posts
- 631
Try this makefile, place a TAB (not spaces!) before the make commands:
Type "make" to make the files and "make clean" to clean them up.Code:obj-m += test.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
Regards
- 03-13-2008 #7Just Joined!
- Join Date
- Feb 2008
- Posts
- 18
compile device driver program
Hi all ,
It works correctly.thanks all .I think it was a good conversation about how to compile the device driver program.once again thanks all to clarify my doubts.
thanks.
with regards
Vivek



