Re: Problem in Compiling Kernel Module

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



hi,
so u have not used the option 
-I/usr/src/linux/include while compiling module or
wherever  yr source of linux  kernel is placed,and
many more errors are even not because  of this also?
Prasanna
> Hi
> 
> I am a Newbie in Kernel Programming and just now
> subscribed to this list. Writing my first kernel
> module and reading Alessandro?s book on Linux Device
> Driver.
> 
> When I compile my simple module with gcc, it
> throughs al bunch of errors.
> 
> As far as I think the errors are because the gcc
> could not find the defination of few of the
> structure used, like struct file, struct inode and
> struct file_operations etc. I have included the
> linux/fs.h file and have also define the required
> macros like MODULE and __KERNEL__, but still not
> able to compile it successfully.
> 
> For debugging, I ran the macro option (-E) of gcc to
> get the output of Macro, so that I could know what
> exactly is included in file before compilation. In
> the Macro output I could not find the definations of
> above mentioned structure, although they are defined
> in linux/fs.h and I have included that file in my
> source.
> 
> I am pasting the output of gcc below.
> 
> Also pasting the source of my module.
> 
> Please have a look at it and help me if you can.
> 
> In source I have left few of the functions like
> open, release etc, blank. I have just started
> writing it and will complete it once I get through
> this problem.
> 
> Details of my system:
> 
> Single Processor
> 
> Redhat Enterprise 3.1
> 
> Kernel: linux-2.4.21-4
> 
> Compiler : gcc 3.2.3.20
> 
> I have one more this to say, when I cteared the
> simple "Hello World" module and compiled it, it
> compiled without any problem, but when I tried to
> load that module in kernel, insmod command gave me
> versioning error. It said that you are trying to
> load the module against different kernel version.
> Well I know it can happen, but my question on this
> is, is it possible that the runnning kernel might be
> different from the kernel in source tree. I did not
> downloaded the source, It?s the default source which
> comes with installation.
> 
> Anyway, please take a look at the errors and source
> to help me out.
> 
>  
> 
>
************************************************************************************************
> 
> Output of gcc
> 
>
************************************************************************************************
> 
> main.c:27: warning: `struct file' declared inside
> parameter list
> 
> main.c:27: warning: its scope is only this
> definition or declaration, which is probably not
> what you want
> 
> main.c:27: warning: `struct inode' declared inside
> parameter list
> 
> main.c:28: warning: `struct file' declared inside
> parameter list
> 
> main.c:29: warning: `struct file' declared inside
> parameter list
> 
> main.c:30: warning: `struct file' declared inside
> parameter list
> 
> main.c:31: warning: `struct file' declared inside
> parameter list
> 
> main.c:31: warning: `struct inode' declared inside
> parameter list
> 
> main.c: In function `fifo_init_module':
> 
> main.c:71: invalid use of undefined type `struct
> file_operations'
> 
> main.c:72: invalid use of undefined type `struct
> file_operations'
> 
> main.c:73: invalid use of undefined type `struct
> file_operations'
> 
> main.c:73: `write' undeclared (first use in this
> function)
> 
> main.c:73: (Each undeclared identifier is reported
> only once
> 
> main.c:73: for each function it appears in.)
> 
> main.c:74: invalid use of undefined type `struct
> file_operations'
> 
> main.c:75: invalid use of undefined type `struct
> file_operations'
> 
> main.c:77: warning: implicit declaration of function
> `register_chrdev'
> 
> main.c:80: warning: implicit declaration of function
> `printk'
> 
> main.c:80: `KERN_EMERG' undeclared (first use in
> this function)
> 
> main.c:80: syntax error before string constant
> 
> main.c: In function `fifo_cleanup_module':
> 
> main.c:101: warning: implicit declaration of
> function `unregister_chrdev'
> 
> main.c:101: `fifo_f_ops' has an incomplete type
> 
> main.c: At top level:
> 
> main.c:122: warning: `struct file' declared inside
> parameter list
> 
> main.c:122: warning: `struct inode' declared inside
> parameter list
> 
> main.c:122: conflicting types for `fifo_open'
> 
> main.c:27: previous declaration of `fifo_open'
> 
> main.c:140: warning: `struct file' declared inside
> parameter list
> 
> main.c:140: conflicting types for `fifo_read'
> 
> main.c:28: previous declaration of `fifo_read'
> 
> main.c:160: warning: `struct file' declared inside
> parameter list
> 
> main.c:160: conflicting types for `fifo_write'
> 
> main.c:29: previous declaration of `fifo_write'
> 
> main.c:175: warning: `struct file' declared inside
> parameter list
> 
> main.c:175: conflicting types for `fifo_llseek'
> 
> main.c:30: previous declaration of `fifo_llseek'
> 
> main.c:194: warning: `struct file' declared inside
> parameter list
> 
> main.c:194: warning: `struct inode' declared inside
> parameter list
> 
> main.c:194: conflicting types for `fifo_release'
> 
> main.c:31: previous declaration of `fifo_release'
> 
> main.c:203: warning: type defaults to `int' in
> declaration of `module_init'
> 
> main.c:203: warning: parameter names (without types)
> in function declaration
> 
> main.c:203: warning: data definition has no type or
> storage class
> 
> main.c:204: warning: type defaults to `int' in
> declaration of `module_exit'
> 
> main.c:204: warning: parameter names (without types)
> in function declaration
> 
> main.c:204: warning: data definition has no type or
> storage class
> 
> main.c:44: storage size of `fifo_f_ops' isn't known
> 
=== message truncated ===



		
__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - Send 10MB messages!
http://promotions.yahoo.com/new_mail 

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux