Re: Link lib to a kernel module



Hello Dipti,

* Dipti Ranjan Tarai <dipti@xxxxxxxxxxxxxxxxxx> [25-10-06 11:16]:
Now in mod2 call test_export() of mod1, compile it and load the module u
can able to access test_export().

thx for that hint, but I want one module :)

I was now successfull with the following code:
hello_lib.h:
int printHello(int);

hello_lib.c
int printHello(int count)
{
int i;

for(i=0;i<=count;i++)
{
printk("Hello World\n");
}

return 0;
}

hello.c:
#include <linux/kernel.h>
#include <linux/module.h>
#include "hello_lib.h"

MODULE_LICENSE("GPL");

int init_module(void)
{
printk("call function\n");
printHello(5);
return 0;
}

void cleanup_module(void)
{
printk(KERN_INFO "remove module\n");
return;
}

Makefile:
KDIR := /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)

obj-m += test.o
test-y := hello.o libhello_lib.a

all:
gcc -I/usr/include -c -o hello_lib.o hello_lib.c
rm -f libhello_lib.a
ar cru libhello_lib.a hello_lib.o
$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules KBUILD_VERBOSE=1


Best regards,
Matthias

--

"Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the universe trying to
produce bigger and better idiots. So far, the universe is winning." --
Rich Cook
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



Relevant Pages

  • Re: initializing int to a number bigger than INT_MAX
    ... I decided to initialize an integer with a number ... >>bigger than INT_MAX, however I still am not able to justify its output. ... > written is a negative number, as you're using a signed int. ... and character or ...
    (comp.lang.c)
  • Re: Question about Files.
    ... > int main{ ... You might consider using the whole word "age" as the variable name. ... Not only that, but you are setting l to 0, then looping while it's bigger ... information on persisting classes in C++. ...
    (comp.lang.cpp)
  • Re: [opensuse] Should I go 64-bit?
    ... more than about 10% bigger. ... 10% bigger and you'd probably need at least 10% more memory to avoid ... Pointers are going to be bigger on the 64bit system, ... It's "substantial" because every pointer and every int is twice as big ...
    (SuSE)
  • Re: Please help optimize (and standarize) this code...
    ... Mark F. Haigh wrote: ... "bigger" ... Wouldn't an implementation with e.g. 16-bit size_t and 32-bit type int ...
    (comp.lang.c)
  • Re: form size height maximum - 1036 ??
    ... This method is declared in the Control class. ... to be bigger than SystemInfo.MaxWindowTrackSize. ... static extern bool MoveWindow(IntPtr hWnd, int X, int Y, int nWidth, int ... > Thanks, Ian. ...
    (microsoft.public.dotnet.framework.windowsforms)