5 Replies - 1281 Views - Last Post: 18 November 2009 - 10:06 PM Rate Topic: -----

#1 Israel  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 7
  • View blog
  • Posts: 818
  • Joined: 22-November 04

Logical Error while Compiling Linux Driver in C

Posted 18 November 2009 - 09:49 PM

Having trouble with this error while trying to compile a basic linux driver.

ERROR:
# make
make -C /lib/modules/2.6.27-1-mepis-smp/build M=/home/Me/C-Dubs/fun modules
make[1]: Entering directory `/usr/src/linux-headers-2.6.27-1-mepis-smp'
  CC [M]  /home/Me/C-Dubs/fun/original.o
/home/Me/C-Dubs/fun/original.c:4:1: warning: "MODULE" redefined
<command line>:1:1: warning: this is the location of the previous definition
/home/Me/C-Dubs/fun/original.c:5:1: warning: "__KERNEL__" redefined
<command line>:1:1: warning: this is the location of the previous definition
/home/Me/C-Dubs/fun/original.c:14: error: conflicting types for 'cleanup_module'
include/linux/module.h:66: error: previous declaration of 'cleanup_module' was here
/home/Me/C-Dubs/fun/original.c:17:2: warning: no newline at end of file
make[2]: *** [/home/Me/C-Dubs/fun/original.o] Error 1
make[1]: *** [_module_/home/Me/C-Dubs/fun] Error 2
make[1]: Leaving directory `/usr/src/linux-headers-2.6.27-1-mepis-smp'
make: *** [all] Error 2



Here is my code:
#include <linux/module.h>
#include <linux/kernel.h>

#define MODULE
#define __KERNEL__

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

int cleanup_module(void)
{
	printk("<1> Into cleanup_module()\n");
	return 0;
}


Is This A Good Question/Topic? 0
  • +

Replies To: Logical Error while Compiling Linux Driver in C

#2 no2pencil  Icon User is online

  • Toubabo Koomi
  • member icon

Reputation: 5313
  • View blog
  • Posts: 27,216
  • Joined: 10-May 07

Re: Logical Error while Compiling Linux Driver in C

Posted 18 November 2009 - 09:50 PM

Since the function cleanup_module is custom, I would try renaming it. Looks like there maybe a conflict somewhere in include/linux/module.h on line 66.
Was This Post Helpful? 0
  • +
  • -

#3 Israel  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 7
  • View blog
  • Posts: 818
  • Joined: 22-November 04

Re: Logical Error while Compiling Linux Driver in C

Posted 18 November 2009 - 09:54 PM

Renaming it to something in module.h?

Or something else random?
Was This Post Helpful? 0
  • +
  • -

#4 no2pencil  Icon User is online

  • Toubabo Koomi
  • member icon

Reputation: 5313
  • View blog
  • Posts: 27,216
  • Joined: 10-May 07

Re: Logical Error while Compiling Linux Driver in C

Posted 18 November 2009 - 09:55 PM

#include <linux/module.h>
#include <linux/kernel.h>

#define MODULE
#define __KERNEL__

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

/* Renamed due to conflict */
int local_cleanup_module(void)
{
	printk("<1> Into local_cleanup_module()\n");
	return 0;
}

Was This Post Helpful? 1
  • +
  • -

#5 Israel  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 7
  • View blog
  • Posts: 818
  • Joined: 22-November 04

Re: Logical Error while Compiling Linux Driver in C

Posted 18 November 2009 - 10:00 PM

That worked! Thanks!

Guess that was random cause I can't find it in module.h. I'll have to remember this.
Was This Post Helpful? 0
  • +
  • -

#6 no2pencil  Icon User is online

  • Toubabo Koomi
  • member icon

Reputation: 5313
  • View blog
  • Posts: 27,216
  • Joined: 10-May 07

Re: Logical Error while Compiling Linux Driver in C

Posted 18 November 2009 - 10:06 PM

According to the error message, it's defined on line 66.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1