All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matthias Fechner <idefix@fechner.net>
To: kbuild-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org
Subject: Re: [kbuild-devel] Link lib to a kernel module
Date: Wed, 25 Oct 2006 14:26:10 +0200	[thread overview]
Message-ID: <20061025122609.GA86838@server.idefix.loc> (raw)
In-Reply-To: <slrnejs14h.93p.olecom@flower.upol.cz>

Hello Oleg,

* Oleg Verych <olecom@flower.upol.cz> [24-10-06 12:11]:
> `Documentation/kbuild' directory in your linux sources.
> `makefiles.txt' about `lib-y',
> `modules.txt'   about modules.

I was now successfull with:
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

  reply	other threads:[~2006-10-25 12:26 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-24 10:55 Link lib to a kernel module Matthias Fechner
2006-10-24 11:12 ` Dipti Ranjan Tarai
2006-10-24 23:35   ` Matthias Fechner
     [not found]     ` <453EFA4C.9000502@innomedia.soft.net>
2006-10-25 12:30       ` Matthias Fechner
2006-10-24 12:11 ` Oleg Verych
2006-10-25 12:26   ` Matthias Fechner [this message]
2006-10-25 18:24     ` Oleg Verych

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20061025122609.GA86838@server.idefix.loc \
    --to=idefix@fechner.net \
    --cc=kbuild-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.