LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 04-19-2006, 07:19 AM   #1
fbarsoba
Member
 
Registered: Dec 2005
Posts: 30

Rep: Reputation: 15
problem compiling kernel module


Hi,

I am really stuck with this thing.. For couple of days i have been trying to compile a kernel module. I have been following the info in http://www.faqs.org/docs/kernel/x204.html. But no success... i recompiled the latest kernel version, and i think i trying to compile the module against the source code for that kernel.. however, strange errors appear.

Please any help will be appreciated.

Here's the error:

Code:
[fbarsoba@localhost ~]$ cd workspace/kernel_tests/
[fbarsoba@localhost kernel_tests]$ make
gcc -O2 -DMODULE -D__KERNEL__ -W -Wall -Wstrict-prototypes -Wmissing-prototypes -isystem /lib/modules/`uname -r`/build/include   -c -o hello-1.o hello-1.c
In file included from /lib/modules/2.6.16.7/build/include/linux/spinlock.h:87,
                 from /lib/modules/2.6.16.7/build/include/linux/capability.h:45,                 from /lib/modules/2.6.16.7/build/include/linux/sched.h:7,
                 from /lib/modules/2.6.16.7/build/include/linux/module.h:10,
                 from hello-1.c:3:
/lib/modules/2.6.16.7/build/include/asm/spinlock.h: In function ‘__raw_spin_lock’:
/lib/modules/2.6.16.7/build/include/asm/spinlock.h:42: error: expected ‘:’ or ‘)’ before ‘KBUILD_BASENAME’
/lib/modules/2.6.16.7/build/include/asm/spinlock.h: In function ‘__raw_read_lock’:
/lib/modules/2.6.16.7/build/include/asm/spinlock.h:96: error: expected ‘:’ or ‘)’ before ‘KBUILD_BASENAME’
/lib/modules/2.6.16.7/build/include/asm/spinlock.h:96: error: expected expression before ‘else’
/lib/modules/2.6.16.7/build/include/asm/spinlock.h: In function ‘__raw_write_lock’:
/lib/modules/2.6.16.7/build/include/asm/spinlock.h:101: error: expected ‘:’ or ‘)’ before ‘KBUILD_BASENAME’
/lib/modules/2.6.16.7/build/include/asm/spinlock.h:101: error: expected expression before ‘else’
In file included from /lib/modules/2.6.16.7/build/include/linux/sched.h:20,
                 from /lib/modules/2.6.16.7/build/include/linux/module.h:10,
                 from hello-1.c:3:
/lib/modules/2.6.16.7/build/include/asm/semaphore.h: In function ‘down’:
/lib/modules/2.6.16.7/build/include/asm/semaphore.h:112: error: expected ‘:’ or ‘)’ before ‘KBUILD_BASENAME’
/lib/modules/2.6.16.7/build/include/asm/semaphore.h: In function ‘down_interruptible’:
/lib/modules/2.6.16.7/build/include/asm/semaphore.h:137: error: expected ‘:’ or ‘)’ before ‘KBUILD_BASENAME’
/lib/modules/2.6.16.7/build/include/asm/semaphore.h: In function ‘down_trylock’:/lib/modules/2.6.16.7/build/include/asm/semaphore.h:161: error: expected ‘:’ or ‘)’ before ‘KBUILD_BASENAME’
/lib/modules/2.6.16.7/build/include/asm/semaphore.h: In function ‘up’:
/lib/modules/2.6.16.7/build/include/asm/semaphore.h:184: error: expected ‘:’ or ‘)’ before ‘KBUILD_BASENAME’
make: *** [hello-1.o] Error 1
And here are the files:

Code:
/*  hello-1.c - The simplest kernel module.
 */
#include <linux/module.h>  /* Needed by all modules */
#include <linux/kernel.h>  /* Needed for KERN_ALERT */


int init_module(void)
{
   printk("<1>Hello world 1.\n");

   // A non 0 return means init_module failed; module can't be loaded.
   return 0;
}


void cleanup_module(void)
{
  printk(KERN_ALERT "Goodbye world 1.\n");
}
Code:
TARGET  := hello-1
WARN    := -W -Wall -Wstrict-prototypes -Wmissing-prototypes
INCLUDE := -isystem /lib/modules/`uname -r`/build/include
CFLAGS  := -O2 -DMODULE -D__KERNEL__ ${WARN} ${INCLUDE}
CC              := gcc

${TARGET}.o:    ${TARGET}.c

.PHONY: clean

clean:
        rm -rf {TARGET}.o
 
Old 04-20-2006, 10:42 AM   #2
Hexstatic
LQ Newbie
 
Registered: Nov 2005
Distribution: Slackware 10.2 (kernel 2.6.16)
Posts: 11

Rep: Reputation: 0
Hi,

I might be wrong but it looks like you're trying to build an old style (2.4 series) module with a 2.6 series kernel, things have changed with 2.6 series for modules, so that code won't work anymore.

There's a hello world module tutorial for 2.6 over here:

http://lwn.net/Articles/driver-porting/

It mentions 2.5 kernels but don't worry about it, i've just tried it with 2.6.16 and it works.

--Hexstatic
 
Old 04-20-2006, 10:55 AM   #3
fbarsoba
Member
 
Registered: Dec 2005
Posts: 30

Original Poster
Rep: Reputation: 15
Yup. That was the problem.. thanks a lot!


Fernando
 
  


Reply


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
compiling only one module without recompiling the kernel l_9_l Linux - General 8 07-06-2009 10:00 PM
compiling single kernel module only evil_empire Linux - Software 2 01-31-2006 12:44 AM
compiling a kernel: module-init-tools conflict, depmod problem, modules sterrenkijker Debian 3 03-08-2004 10:07 PM
compiling a kernel module for a different target akaBeaVis Linux - Software 10 06-09-2003 12:47 AM
Kernel compiling and module compiling tarballed Linux - General 1 12-22-2002 05:31 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 09:34 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
Open Source Consulting | Domain Registration