LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   compiling a module (https://www.linuxquestions.org/questions/programming-9/compiling-a-module-245520/)

eltn 10-21-2004 09:13 AM

compiling a module
 
hellow

i tried to compile a simple module

in first i printed

gcc -c hello.c
(created hello.o)

and then

insmod hello.o
(i tried also insmod -f hello.o)
but its printed me an error
hello.o: couldnt find the kernel version the module was compile for?

is anyone know a solution?

sjalex 10-21-2004 09:37 AM

uhm! That doesn't look like a kernel module... Is this a program you wrote or what?

Perhaps you should consider dropping the -c flag if you're trying to make an executable...

eltn 10-21-2004 10:06 AM

its a module that i wrote

sjalex 10-22-2004 08:08 AM

ah, OK, I'm gonna go out on a limb and assume you've not done any kernel development before.

What are you trying to do with this module you wrote? I mean, what is it supposed to do?

eltn 10-22-2004 09:32 AM

module
 
u r right i dont know mutch about the kernel development

i got a project (from the uni)

this is the project


3. The /proc file system.
(a) Add a file to /proc that will give the number of system calls executed
since the system has been booted. (2)
(b) Add a file to /proc/(pid) directory called \trace" that when read will
give a list of executed system calls by number. (2)

Ojp 04-01-2006 07:30 PM

I give you a little code, you need to create a Makefile like this (more info in Documentation/Kbuild/Meakefiles.txt):

obj-m := main.o
sadoo-objs := main.o


When you compile your module, do this:

$make -C (the path of your kernel source) M=$PWD modules


The path of kernel soure must be the same path of the kernel that you use in your system, don't work at all if you use a source that you downloaded. In my case I use the path like this (I have RHEL 4): /usr/src/kernels/2.6.9-5.EL-i686


All times are GMT -5. The time now is 02:55 PM.