openSUSE Forums > Programming/Scripting » "hello world" module wont compile

Go Back   openSUSE Forums > Programming/Scripting
Forums FAQ Members List Search Today's Posts Mark Forums Read


Programming/Scripting Questions about programming, bash scripts, perl, php, cron jobs, ruby, python, etc.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 15-Aug-2008, 17:52
Puzzled Penguin
 
Join Date: Aug 2008
Posts: 8
aveceena hasn't been rated much yet
Default "hello world" module wont compile

Same module install/works on FC6 machine.
here are the out puts.
I have installed
1-linux-kernel-header
2-kernel-source
3-kernel-syms
installed.

MAke file
Code:
champ@linux-r9za:~/driver> ls
Makefile  hello-1.c

champ@linux-r9za:~/driver> cat Makefile 

bj-m += hello-1.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
Hello world module, it complie runs on my FC6 machine.
Code:
champ@linux-r9za:~/driver> 
champ@linux-r9za:~/driver> cat hello-1.c 
#include <linux/module.h>	/* Needed by all modules */
#include <linux/kernel.h>	/* Needed for KERN_INFO */

int init_module(void)
{
	printjkk(KERN_INFO "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_INFO "Goodbye world 1.\n");
}
Build process:

Code:
 make
make -C /lib/modules/2.6.25.5-1.1-pae/build M=/home/champ modules
make[1]: Entering directory `/usr/src/linux-2.6.25.5-1.1-obj/i386/pae'
make[1]: *** No rule to make target `modules'.  Stop.
make[1]: Leaving directory `/usr/src/linux-2.6.25.5-1.1-obj/i386/pae'
make: *** [all] Error 2
champ@linux-i5hb:~>

I think I have every thing installed

Code:
p@linux-i5hb:~> rpm -qa | grep kernel
linux-kernel-headers-2.6.25-8.1
kernel-syms-2.6.25.11-0.1
kernel-pae-2.6.25.5-1.1
kernel-source-2.6.25.11-0.1
champ@linux-i5hb:~>

Any Ideas?

Thanks.
Reply With Quote
  #2 (permalink)  
Old 15-Aug-2008, 21:25
lornix's Avatar
Parent Penguin
 
Join Date: Jun 2008
Location: Oklahoma, US
Posts: 834
lornix hasn't been rated much yet
Send a message via AIM to lornix Send a message via Yahoo to lornix
Default Re: "hello world" module wont compile


Some initial observations:

From hello-1.c:
You have misspelled 'printk' as 'printjkk' in 'init_module',
this will cause an error.
You have an extra '{' just prior to 'void cleanup_module...',
this will cause an error.
From Makefile:
You are missing the letter 'o' on the first line, this should
read 'obj-m += hello-1.o'

I have fixed these errors to facilitate my testing.

After fixing the above errors, the module compiles cleanly.

Make those changes as noted, should work for you.

Loni

--
L R Nix
lornix@lornix.com

Reply With Quote
  #3 (permalink)  
Old 15-Aug-2008, 21:30
lornix's Avatar
Parent Penguin
 
Join Date: Jun 2008
Location: Oklahoma, US
Posts: 834
lornix hasn't been rated much yet
Send a message via AIM to lornix Send a message via Yahoo to lornix
Default Re: "hello world" module wont compile


As an afterthought, your errors you posted reminded me of a recent experience
with a module...

You *may* need to either reinstall kernel-source (which would reset some
files and links needed) --OR-- execute the following: (as root)

cd /usr/src/linux
make cloneconfig
make
make modules_install
make install

and then reboot.

This will recreate some necessary links and file within the linux and
linux-obj directory structures needed to compile modules.

Loni

--
L R Nix
lornix@lornix.com

Reply With Quote
  #4 (permalink)  
Old 17-Aug-2008, 15:52
Puzzled Penguin
 
Join Date: Aug 2008
Posts: 8
aveceena hasn't been rated much yet
Default Re: "hello world" module wont compile

Thanks!
recompiling kernel solved the issue.

But new kernel have issue with ndiswrapper. After I install driver I do
#modprobe ndiswraper
It says driver module not found.

Any idea?

thanks.
Reply With Quote
  #5 (permalink)  
Old 17-Aug-2008, 19:32
lornix's Avatar
Parent Penguin
 
Join Date: Jun 2008
Location: Oklahoma, US
Posts: 834
lornix hasn't been rated much yet
Send a message via AIM to lornix Send a message via Yahoo to lornix
Default Re: "hello world" module wont compile

On Sun, 17 Aug 2008 20:56:03 GMT
aveceena <aveceena@no-mx.forums.opensuse.org> wrote:

>
> Thanks!
> recompiling kernel solved the issue.
>
> But new kernel have issue with ndiswrapper. After I install driver I do
>
> #modprobe ndiswraper
> It says driver module not found.
>
> Any idea?
>
> thanks.
>
>


Well, you recompiled the kernel....

Did you recompile the ndiswrapper module?

They have to match... and old-kernel ndiswrapper doesn't match new-kernel.

Yes, it's that picky. (You *can* make it less picky... but I doubt you'll
need to recompile the kernel any more)

Loni

--
L R Nix
lornix@lornix.com

Reply With Quote
Reply

Bookmarks


Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




 

Search Engine Friendly URLs by vBSEO 3.3.2