Juan Gonzalez wrote:
> 
> Here's a simple example that may help in resolving this issue.
> 
> Below I'm attaching the source code for a bare-minimum module (based on an
> example from Rubini's book).  While running Linux 2.2.12-20smp, I compile the
> code below with "gcc -c hello.c", producing the module "hello.o" .  However,
> insmod complains:
> 
> root#  gcc -c hello.c
> root#  /sbin/insmod hello
> ./hello.o: unresolved symbol printk
> 
> Could someone out there please try this on your smp system and let me know your
> results?  Thanks.
> 
> My questions are:
> 1.  Is there something wrong with how I'm building the module, or is there a
> problem with my smp installation?
The compilation options suggested before are really necessary, -Wall,
for example would have told you that you were not prototyping printk,
which means you need to add a header file for it.

You should try to compile your modules with something like this:

gcc -D__SMP__ -D__KERNEL__ -DMODULE -O2 -Wall -I/usr/src/linux/include
-Wstrict-prototypes -fomit-frame-pointer -fno-strength-reduce -pipe
-m486 -malign-loops=2 -malign-jumps=2 -malign-functions=2 -DCPU=586 -c
-o hello.o hello.c

> 2.  What can I do to resolve this?

------- hello.c
#include <linux/kernel.h>
#include <linux/module.h>

int init_module(void)
{
  printk("<1>Hello, world\n");
  return 0;
}

void cleanup_module(void)
{
  printk("<1>Goodbye cruel world\n");
}
-------

The above should work.
-- 
Rafael Herrera
-
Linux SMP list: FIRST see FAQ at http://www.irisa.fr/prive/dmentre/smp-howto/
To Unsubscribe: send "unsubscribe linux-smp" to [EMAIL PROTECTED]

Reply via email to