LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices



Reply
 
Search this Thread
Old 06-12-2008, 05:58 AM   #1
pranav_patil
LQ Newbie
 
Registered: Jun 2008
Location: Pune, India
Posts: 4

Rep: Reputation: 0
Post Could not compile sample driver module in Suse 10.3


I was trying to compile a module to create a sample driver.
Initially I tried to compile a dummy module and load in the system
using the command,

gcc -D_KERNEL_ -I/usr/src/linux/include -DMODULE -Wall -O2 -c hello.c

The code for hello.c is as follows:

#include <linux/module.h> /* Needed by all modules */
#include <linux/kernel.h> /* Needed for KERN_INFO */
#include <linux/init.h> /* Needed for the macros */

static int __init hello_start(void)
{
printk(KERN_INFO "Loading hello module...\n");
printk(KERN_INFO "Hello world\n");
return 0;
}

static void __exit hello_end(void)
{
printk(KERN_INFO "Goodbye Mr.\n");
}

module_init(hello_start);
module_exit(hello_end);

I get the errors as follows:

error : asm/bitops.h : No such file or directory.
error : asm/thread_info.h : No such file or directory.
error : thread_info.h : In function 'set_ti_thread_flag'.
error : asm/linkage.h : No such file or directory.
error : asm/bug.h : No such file or directory.
error : asm/system.h : No such file or directory.
error : asm/atomic.h : No such file or directory.
error : asm/module.h : No such file or directory.
error : asm/processor.h : No such file or directory.
error : asm/cache.h : No such file or directory.
error : asm/current.h : No such file or directory.
error : asm/local.h : No such file or directory.

The above was the brief summary of errors what I was getting.
Can you help me with the problem and find a suitable solution ?
 
Old 06-14-2008, 02:36 AM   #2
komodo
Member
 
Registered: Jun 2008
Distribution: linux from scratch, Arch linux
Posts: 39

Rep: Reputation: 15
My guess is that you did not install the kernel header files before compiling this.
 
Old 06-14-2008, 08:36 AM   #3
pranav_patil
LQ Newbie
 
Registered: Jun 2008
Location: Pune, India
Posts: 4

Original Poster
Rep: Reputation: 0
I installed the entire kernel package from suse installation disc. But there is no folder
such as /usr/src/linux/include/linux/asm . There are folders like /usr/src/linux/include/linux/asmi386 and others.
 
Old 06-14-2008, 09:40 AM   #4
komodo
Member
 
Registered: Jun 2008
Distribution: linux from scratch, Arch linux
Posts: 39

Rep: Reputation: 15
ok, so, the headers are found in a different directory than gcc thinks. In that case, you may have to change the prefix.
you have tried
Code:
gcc -D_KERNEL_ -I/usr/src/linux/include -DMODULE -Wall -O2 -c hello.c
this basically tells gcc to look for the include files in the path /usr/src/linux/include/... However, as you have found, on your system the correct path should be /usr/src/linux/include/linux/.... So, maybe you should try this:

Code:
gcc -D_KERNEL_ -I/usr/src/linux/include/linux -DMODULE -Wall -O2 -c hello.c
If that doesn't work, we'll continue the search...(you may then have to set a symlink to an alternative directory name and point gcc to that)...on the other hand, perhaps other have a quick solution...

Last edited by komodo; 06-14-2008 at 09:44 AM.
 
Old 06-20-2008, 09:56 AM   #5
pranav_patil
LQ Newbie
 
Registered: Jun 2008
Location: Pune, India
Posts: 4

Original Poster
Rep: Reputation: 0
Now I changed My code to as follows :

hello.c ..............

#include <module.h>

#if defined(CONFIG_SMP)
#define __SMP__
#endif

#if defined(CONFIG_MODVERSIONS)
#define MODVERSIONS
#include <modversions.h>
#endif

#include <kernel.h>

int init_module(void)
{
printk("<7>Hello, kernel!!\n");
return 0;
}

void cleanup_module(void)
{
printk("<7>Good-bye, kernel!!\n");
}
--------------------------------------------------------------------------
Executed the command you told :
gcc -D _KERNEL_ -I/usr/src/linux/include/linux -DMODULE -Wall -O2 -c hello.c

I got the following errors:

In file included from hello.c:2:
/usr/src/linux/include/linux/module.h:9:28: error: linux/spinlock.h: No such file or directory
/usr/src/linux/include/linux/module.h:10:24: error: linux/list.h: No such file or directory
/usr/src/linux/include/linux/module.h:12:28: error: linux/compiler.h: No such file or directory
/usr/src/linux/include/linux/module.h:13:25: error: linux/cache.h: No such file or directory
/usr/src/linux/include/linux/module.h:14:24: error: linux/kmod.h: No such file or directory
/usr/src/linux/include/linux/module.h:16:29: error: linux/stringify.h: No such file or directory
/usr/src/linux/include/linux/module.h:17:27: error: linux/kobject.h: No such file or directory
/usr/src/linux/include/linux/module.h:18:31: error: linux/moduleparam.h: No such file or directory
/usr/src/linux/include/linux/module.h:19:23: error: asm/local.h: No such file or directory
/usr/src/linux/include/linux/module.h:21:24: error: asm/module.h: No such file or directory
In file included from hello.c:2:
/usr/src/linux/include/linux/module.h:48: error: field ‚€˜attr‚€™ has incomplete type
/usr/src/linux/include/linux/module.h:59: error: field ‚€˜kobj‚€™ has incomplete type
/usr/src/linux/include/linux/module.h: In function ‚€˜lookup_module_symbol_name‚€™:
/usr/src/linux/include/linux/module.h:535: error: ‚€˜ERANGE‚€™ undeclared (first use in this function)
/usr/src/linux/include/linux/module.h:535: error: (Each undeclared identifier is reported only once
/usr/src/linux/include/linux/module.h:535: error: for each function it appears in.)
/usr/src/linux/include/linux/module.h: In function ‚€˜lookup_module_symbol_attrs‚€™:
/usr/src/linux/include/linux/module.h:540: error: ‚€˜ERANGE‚€™ undeclared (first use in this function)
/usr/src/linux/include/linux/module.h: In function ‚€˜module_get_kallsym‚€™:
/usr/src/linux/include/linux/module.h:547: error: ‚€˜ERANGE‚€™ undeclared (first use in this function)
/usr/src/linux/include/linux/module.h: At top level:
/usr/src/linux/include/linux/module.h:596: warning: ‚€˜struct kernel_param‚€™ declared inside parameter list
/usr/src/linux/include/linux/module.h:596: warning: its scope is only this definition or declaration, which is probably not what you want
hello.c: In function ‚€˜init_module‚€™:
hello.c:17: warning: implicit declaration of function ‚€˜printk‚€™

The text is corrupted because of the transferring of data from linux to windows.
Can you help me with the problem please ?
 
  


Reply

Tags
compilation, kernel, module


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Driver Module code cannot compile in Mandriva 2006, need advise SPo2 Linux - Software 0 09-29-2007 01:04 AM
Ati Driver Installation Problem (can't compile kernel module) verdeboy2k Linux - Hardware 3 05-16-2006 03:24 AM
how to compile driver module for sound blaster live 24bit? lnthai2002 Linux - Enterprise 0 03-24-2006 12:32 PM
Kernel compile breaks both nvidia driver module and dirver installation darkleaf Linux - Software 9 08-19-2004 05:24 PM
Sample Driver Module incompatibility with Kernel version (or gcc version) jvs Linux - General 1 06-07-2002 02:40 AM


All times are GMT -5. The time now is 01:13 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration