Discussion:
Error building 'Hello,World' kernel Module
Lei Yang
2004-08-04 22:43:40 UTC
Permalink
Hello,

I am learning about module programming and just tried to build a
simplest module, Hello World.

The code is as follows:
/* hello.c
#include <linux/module.h>
#include <linux/kernel.h>

int init_module(void)
{
printk("Hello world!\n");
return 0;
}

void cleanup_module(void)
{
printk(KERN_ALERT "Goodbye world!\n");
}


The makefile is just one line:
obj-m += hello.o

Then as root, I did in the HelloWorld directory:

make -C /usr/src/linux-`uname -r` SUBDIRS=$PWD modules

There is such an error:
make: Entering directory `/usr/src/linux-2.6.5-7.104-default'

WARNING: Symbol version dump
/usr/src/linux-2.6.5-7.104-default/Module.symvers is missing, modules
will have CONFIG_MODVERSIONS disabled.

make[1]: *** No rule to make target `/home/lei/HelloWorld/hello.c',
needed by `/home/lei/HelloWorld/hello.o'. Stop.
make: *** [_module_/home/lei/HelloWorld] Error 2
make: Leaving directory `/usr/src/linux-2.6.5-7.104-default'


Appreciate any comments and help!

TIA
Lei


-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to ***@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
Hinko Kocevar
2004-08-04 20:13:53 UTC
Permalink
Post by Lei Yang
Hello,
...
Did you read article about porting device drivers to 2.6 at
http://lwn.net/Articles/driver-porting/? This one would be of interest
to you in particular http://lwn.net/Articles/21817/.

regards,
h
--
hinko <dot> kocevar <at> iskramedical <dot> si
Hinko Kocevar, developer
Iskra Medical d.o.o., Stegne 23, 1k LJ, SLO-EU

"Aì rén" | [Analects XII:22]

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/kernelnewbies/
FAQ: http://kernelnewbies.org/faq/
Lei Yang
2004-08-06 00:11:55 UTC
Permalink
Thank you so much Hinko! I owe you a beer:)
It's truely the problem of makefile, now the "Hello World" works!
Post by Hinko Kocevar
Post by Lei Yang
Hello,
...
Did you read article about porting device drivers to 2.6 at
http://lwn.net/Articles/driver-porting/? This one would be of interest
to you in particular http://lwn.net/Articles/21817/.
regards,
h
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/kernelnewbies/
FAQ: http://kernelnewbies.org/faq/
suneesh
2004-08-05 04:27:50 UTC
Permalink
Hi

Create a makefile like this :

KERNELDIR = /usr/src/linux-2.4 (change this according to your Kernel dir)

include $(KERNELDIR)/.config

CFLAGS = -I$(KERNELDIR)/include -O -Wall

all: hello.o

and try 'make' ....U can refer Rubini's Linux Device Drivers, chapter2

http://www.xml.com/ldd/chapter/book/ch02.html

Regards

Suneesh
Post by Lei Yang
Hello,
I am learning about module programming and just tried to build a
simplest module, Hello World.
/* hello.c
#include <linux/module.h>
#include <linux/kernel.h>
int init_module(void)
{
printk("Hello world!\n");
return 0;
}
void cleanup_module(void)
{
printk(KERN_ALERT "Goodbye world!\n");
}
obj-m += hello.o
make -C /usr/src/linux-`uname -r` SUBDIRS=$PWD modules
make: Entering directory `/usr/src/linux-2.6.5-7.104-default'
WARNING: Symbol version dump
/usr/src/linux-2.6.5-7.104-default/Module.symvers is missing, modules
will have CONFIG_MODVERSIONS disabled.
make[1]: *** No rule to make target `/home/lei/HelloWorld/hello.c',
needed by `/home/lei/HelloWorld/hello.o'. Stop.
make: *** [_module_/home/lei/HelloWorld] Error 2
make: Leaving directory `/usr/src/linux-2.6.5-7.104-default'
Appreciate any comments and help!
TIA
Lei
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/kernelnewbies/
FAQ: http://kernelnewbies.org/faq/
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/kernelnewbies/
FAQ: http://kernelnewbies.org/faq/
Lei Yang
2004-08-05 22:41:35 UTC
Permalink
Yeah, I have a 2.6.5 kernel, and I want to build the module with kbuild
infrastrature. That's why the makefile is only obj-m += hello.o.

I followed this howto

http://www.tldp.org/LDP/lkmpg/2.6/html/x149.html

And I am sure it should work, just what is wrong with mine:(

Thanks.
Lei
Post by suneesh
Hi
KERNELDIR = /usr/src/linux-2.4 (change this according to your Kernel dir)
include $(KERNELDIR)/.config
CFLAGS = -I$(KERNELDIR)/include -O -Wall
all: hello.o
and try 'make' ....U can refer Rubini's Linux Device Drivers, chapter2
http://www.xml.com/ldd/chapter/book/ch02.html
Regards
Suneesh
Post by Lei Yang
Hello,
I am learning about module programming and just tried to build a
simplest module, Hello World.
/* hello.c
#include <linux/module.h> #include <linux/kernel.h>
int init_module(void)
{
printk("Hello world!\n");
return 0;
}
void cleanup_module(void)
{
printk(KERN_ALERT "Goodbye world!\n");
}
obj-m += hello.o
make -C /usr/src/linux-`uname -r` SUBDIRS=$PWD modules
make: Entering directory `/usr/src/linux-2.6.5-7.104-default'
WARNING: Symbol version dump
/usr/src/linux-2.6.5-7.104-default/Module.symvers is missing, modules
will have CONFIG_MODVERSIONS disabled.
make[1]: *** No rule to make target `/home/lei/HelloWorld/hello.c',
needed by `/home/lei/HelloWorld/hello.o'. Stop.
make: *** [_module_/home/lei/HelloWorld] Error 2
make: Leaving directory `/usr/src/linux-2.6.5-7.104-default'
Appreciate any comments and help!
TIA
Lei
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/kernelnewbies/
FAQ: http://kernelnewbies.org/faq/
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/kernelnewbies/
FAQ: http://kernelnewbies.org/faq/
Shine Mohamed Jabbar
2004-08-05 05:17:14 UTC
Permalink
Hi,

I tried ur program in my machine and
its working fine.

Apart from what u've done I did two more things
1) Copied the config file from the /boot to kernel
source directory and done "make menuconfig"

2) Done a make in the kernel source till it compiles
the first c file (CC init/main.o). (I've done
because to make a link of include/asm->include/asm-i386).

Regards,
Shine Mohamed Jabbar
Post by Lei Yang
Hello,
I am learning about module programming and just tried to build a
simplest module, Hello World.
/* hello.c
#include <linux/module.h>
#include <linux/kernel.h>
int init_module(void)
{
printk("Hello world!\n");
return 0;
}
void cleanup_module(void)
{
printk(KERN_ALERT "Goodbye world!\n");
}
obj-m += hello.o
make -C /usr/src/linux-`uname -r` SUBDIRS=$PWD modules
make: Entering directory `/usr/src/linux-2.6.5-7.104-default'
WARNING: Symbol version dump
/usr/src/linux-2.6.5-7.104-default/Module.symvers is missing, modules
will have CONFIG_MODVERSIONS disabled.
make[1]: *** No rule to make target `/home/lei/HelloWorld/hello.c',
needed by `/home/lei/HelloWorld/hello.o'. Stop.
make: *** [_module_/home/lei/HelloWorld] Error 2
make: Leaving directory `/usr/src/linux-2.6.5-7.104-default'
Appreciate any comments and help!
TIA
Lei
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/kernelnewbies/
FAQ: http://kernelnewbies.org/faq/
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to ***@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
Lei Yang
2004-08-05 22:44:06 UTC
Permalink
Post by Shine Mohamed Jabbar
Hi,
I tried ur program in my machine and
its working fine.
Apart from what u've done I did two more things
1) Copied the config file from the /boot to kernel
source directory and done "make menuconfig"
I didn't copy anything to kernel source, I just did 'make oldconfig'
Post by Shine Mohamed Jabbar
2) Done a make in the kernel source till it compiles
the first c file (CC init/main.o). (I've done
because to make a link of include/asm->include/asm-i386).
Is this really necessary...? I don't know. I didn't do that. I thought
all the information module needed is the kernel configuration.

Thanks.
Lei
Post by Shine Mohamed Jabbar
Regards,
Shine Mohamed Jabbar
Post by Lei Yang
Hello,
I am learning about module programming and just tried to build a
simplest module, Hello World.
/* hello.c
#include <linux/module.h>
#include <linux/kernel.h>
int init_module(void)
{
printk("Hello world!\n");
return 0;
}
void cleanup_module(void)
{
printk(KERN_ALERT "Goodbye world!\n");
}
obj-m += hello.o
make -C /usr/src/linux-`uname -r` SUBDIRS=$PWD modules
make: Entering directory `/usr/src/linux-2.6.5-7.104-default'
WARNING: Symbol version dump
/usr/src/linux-2.6.5-7.104-default/Module.symvers is missing, modules
will have CONFIG_MODVERSIONS disabled.
make[1]: *** No rule to make target `/home/lei/HelloWorld/hello.c',
needed by `/home/lei/HelloWorld/hello.o'. Stop.
make: *** [_module_/home/lei/HelloWorld] Error 2
make: Leaving directory `/usr/src/linux-2.6.5-7.104-default'
Appreciate any comments and help!
TIA
Lei
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/kernelnewbies/
FAQ: http://kernelnewbies.org/faq/
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/kernelnewbies/
FAQ: http://kernelnewbies.org/faq/
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to ***@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
Shine Mohamed Jabbar
2004-08-06 05:20:46 UTC
Permalink
Post by Lei Yang
Post by Shine Mohamed Jabbar
Hi,
I tried ur program in my machine and
its working fine.
Apart from what u've done I did two more things
1) Copied the config file from the /boot to kernel
source directory and done "make menuconfig"
I didn't copy anything to kernel source, I just did 'make oldconfig'
Thats fine..
Post by Lei Yang
Post by Shine Mohamed Jabbar
2) Done a make in the kernel source till it compiles
the first c file (CC init/main.o). (I've done
because to make a link of include/asm->include/asm-i386).
Is this really necessary...? I don't know. I didn't do that. I thought
all the information module needed is the kernel configuration.
In my case the soft link {KERNEL SRC}/include/asm was not defined.
Without that soft link it was not possible to include arch specific
header files.

So when I did a "make" (for first/one time) that link came
automatically (by some scripts). Am I right ?

Thanks and Regards,
Shine Mohamed Jabbar
Post by Lei Yang
Thanks.
Lei
Post by Shine Mohamed Jabbar
Regards,
Shine Mohamed Jabbar
Post by Lei Yang
Hello,
I am learning about module programming and just tried to build a
simplest module, Hello World.
/* hello.c
#include <linux/module.h>
#include <linux/kernel.h>
int init_module(void)
{
printk("Hello world!\n");
return 0;
}
void cleanup_module(void)
{
printk(KERN_ALERT "Goodbye world!\n");
}
obj-m += hello.o
make -C /usr/src/linux-`uname -r` SUBDIRS=$PWD modules
make: Entering directory `/usr/src/linux-2.6.5-7.104-default'
WARNING: Symbol version dump
/usr/src/linux-2.6.5-7.104-default/Module.symvers is missing, modules
will have CONFIG_MODVERSIONS disabled.
make[1]: *** No rule to make target `/home/lei/HelloWorld/hello.c',
needed by `/home/lei/HelloWorld/hello.o'. Stop.
make: *** [_module_/home/lei/HelloWorld] Error 2
make: Leaving directory `/usr/src/linux-2.6.5-7.104-default'
Appreciate any comments and help!
TIA
Lei
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/kernelnewbies/
FAQ: http://kernelnewbies.org/faq/
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/kernelnewbies/
FAQ: http://kernelnewbies.org/faq/
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/kernelnewbies/
FAQ: http://kernelnewbies.org/faq/
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to ***@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
pa3gcu
2004-08-06 05:59:36 UTC
Permalink
Post by Shine Mohamed Jabbar
In my case the soft link {KERNEL SRC}/include/asm was not defined.
Without that soft link it was not possible to include arch specific
header files.
So when I did a "make" (for first/one time) that link came
automatically (by some scripts). Am I right ?
You are correct in using make, but in 2.6 kernels you can use;
make symlinks
In 2.4 kernels 'make dep' does the job.
Its not a script its the Makefile via make that places symlinks in 2.6
kernels.
Post by Shine Mohamed Jabbar
Thanks and Regards,
Shine Mohamed Jabbar
--
If the Linux community is a bunch of thieves because they
try to imitate windows programs, then the Windows community
is built on organized crime.

Regards Richard
***@zeelandnet.nl
http://people.zeelandnet.nl/pa3gcu/


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