What are we doing wrong? - Nav & Michael
**************************************************
hello.c Source:
#include "/home/mzhu/linux/include/linux/config.h"
/*retrieve the CONFIG_* macros */
#if defined(CONFIG_MODVERSIONS) && !defined(MODVERSIONS)
#define MODVERSIONS /* force it on */
#endif
#ifdef MODVERSIONS
#include "/home/mzhu/linux/include/linux/modversions.h"
#endif
#include "/home/mzhu/linux/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"); }
Output:
#>gcc -D_KERNEL_ -DMODULE -c hello.c
[This builds the hello.o file. ]
#>insmod hello.o
hello.o : unresolved symbol printk
hello.o : Note: modules without a GPL compatible license cannot use
GPONLY_symbols
You need to define the __KERNEL__ and MODULE symbols
#define __KERNEL__
#define MODULE
>>> Nav Mundi <[email protected]> 12/04/01 09:33AM >>>
What are we doing wrong? - Nav & Michael
**************************************************
hello.c Source:
#include "/home/mzhu/linux/include/linux/config.h"
/*retrieve the CONFIG_* macros */
#if defined(CONFIG_MODVERSIONS) && !defined(MODVERSIONS)
#define MODVERSIONS /* force it on */
#endif
#ifdef MODVERSIONS
#include "/home/mzhu/linux/include/linux/modversions.h"
#endif
#include "/home/mzhu/linux/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"); }
Output:
#>gcc -D_KERNEL_ -DMODULE -c hello.c
[This builds the hello.o file. ]
#>insmod hello.o
hello.o : unresolved symbol printk
hello.o : Note: modules without a GPL compatible license cannot use
GPONLY_symbols
I've define these two when I compile the module. The
command line is:
gcc -D_KERNEL_ -DMODULE -c hello.c
--- Tyler BIRD <[email protected]> wrote:
> You need to define the __KERNEL__ and MODULE symbols
>
> #define __KERNEL__
> #define MODULE
>
>
> >>> Nav Mundi <[email protected]> 12/04/01 09:33AM
> >>>
> What are we doing wrong? - Nav & Michael
> **************************************************
>
> hello.c Source:
>
> #include "/home/mzhu/linux/include/linux/config.h"
> /*retrieve the CONFIG_* macros */
> #if defined(CONFIG_MODVERSIONS) &&
> !defined(MODVERSIONS)
> #define MODVERSIONS /* force it on */
> #endif
>
> #ifdef MODVERSIONS
> #include
> "/home/mzhu/linux/include/linux/modversions.h"
> #endif
>
> #include "/home/mzhu/linux/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"); }
>
> Output:
>
> #>gcc -D_KERNEL_ -DMODULE -c hello.c
>
> [This builds the hello.o file. ]
>
> #>insmod hello.o
>
> hello.o : unresolved symbol printk
> hello.o : Note: modules without a GPL compatible
> license cannot use
> GPONLY_symbols
>
>
>
>
> -
> To unsubscribe from this list: send the line
> "unsubscribe linux-kernel" in
> the body of a message to [email protected]
> More majordomo info at
> http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
______________________________________________________
Send your holiday cheer with http://greetings.yahoo.ca
_KERNEL_ != __KERNEL__
gcc -D__KERNEL__ -DMODULE -c hello.c
> gcc -D_KERNEL_ -DMODULE -c hello.c
>
> --- Tyler BIRD <[email protected]> wrote:
> > You need to define the __KERNEL__ and MODULE symbols
> >
> > #define __KERNEL__
> > #define MODULE
> >
> >
> > >>> Nav Mundi <[email protected]> 12/04/01 09:33AM
> > >>>
> > What are we doing wrong? - Nav & Michael
> > **************************************************
> >
> > hello.c Source:
> >
> > #include "/home/mzhu/linux/include/linux/config.h"
> > /*retrieve the CONFIG_* macros */
> > #if defined(CONFIG_MODVERSIONS) &&
> > !defined(MODVERSIONS)
> > #define MODVERSIONS /* force it on */
> > #endif
> >
> > #ifdef MODVERSIONS
> > #include
> > "/home/mzhu/linux/include/linux/modversions.h"
> > #endif
> >
> > #include "/home/mzhu/linux/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"); }
> >
> > Output:
> >
> > #>gcc -D_KERNEL_ -DMODULE -c hello.c
> >
> > [This builds the hello.o file. ]
> >
> > #>insmod hello.o
> >
> > hello.o : unresolved symbol printk
> > hello.o : Note: modules without a GPL compatible
> > license cannot use
> > GPONLY_symbols
> >
> >
> >
> >
> > -
> > To unsubscribe from this list: send the line
> > "unsubscribe linux-kernel" in
> > the body of a message to [email protected]
> > More majordomo info at
> > http://vger.kernel.org/majordomo-info.html
> > Please read the FAQ at http://www.tux.org/lkml/
> >
>
>
> ______________________________________________________
> Send your holiday cheer with http://greetings.yahoo.ca
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
On Tue, 4 Dec 2001, Michael Zhu wrote:
| I've define these two when I compile the module. The
| command line is:
|
| gcc -D_KERNEL_ -DMODULE -c hello.c
Check the spelling of "__KERNEL__".
~Randy
| --- Tyler BIRD <[email protected]> wrote:
| > You need to define the __KERNEL__ and MODULE symbols
| >
| > #define __KERNEL__
| > #define MODULE
| >
| >
| > >>> Nav Mundi <[email protected]> 12/04/01 09:33AM
| > >>>
| > What are we doing wrong? - Nav & Michael
| > **************************************************
| >
| > hello.c Source:
| >
| > #include "/home/mzhu/linux/include/linux/config.h"
| > /*retrieve the CONFIG_* macros */
| > #if defined(CONFIG_MODVERSIONS) &&
| > !defined(MODVERSIONS)
| > #define MODVERSIONS /* force it on */
| > #endif
| >
| > #ifdef MODVERSIONS
| > #include
| > "/home/mzhu/linux/include/linux/modversions.h"
| > #endif
| >
| > #include "/home/mzhu/linux/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"); }
| >
| > Output:
| >
| > #>gcc -D_KERNEL_ -DMODULE -c hello.c
| >
| > [This builds the hello.o file. ]
| >
| > #>insmod hello.o
| >
| > hello.o : unresolved symbol printk
| > hello.o : Note: modules without a GPL compatible
| > license cannot use
| > GPONLY_symbols
I've changed my source file like this:
#define MODULE
#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"); }
And I use the following message to build the module.
But when I use insmod to load the module I got the
following error message:
hello.o : kernel-module version mismatch
hello.o was compiled for kernel version
2.4.12
while this kernel is version 2.4.8
What is wrong? My kernel version is 2.4.8. Is there
something wrong with the gcc compilier? My gcc
compilier is gcc-2.95.
Thanks to everyone. Your help is very beneficial to
me.
Michael
--- Christine Ames <[email protected]> wrote:
> > -----Original Message-----
> > From: Michael Zhu [mailto:[email protected]]
> > Sent: Tuesday, December 04, 2001 9:07 AM
>
> <snip>
>
> >
> >
> > I've define these two when I compile the module.
> The
> > command line is:
> >
> > gcc -D_KERNEL_ -DMODULE -c hello.c
> >
> >
> <snip>
> >
>
> See http://www.xml.com/ldd/chapter/book/ch02.html
>
> Where your source should be similar to:
>
> #define MODULE // <- HERE!!! define MODULE
> #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"); }
>
______________________________________________________
Send your holiday cheer with http://greetings.yahoo.ca
I've changed my source file like this:
#define MODULE
#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"); }
And I use the following command line to build the
module.
gcc -c -D__KERNEL__ hello.c
But when I use insmod to load the module I got the
following error message:
hello.o : kernel-module version mismatch
hello.o was compiled for kernel version
2.4.12
while this kernel is version 2.4.8
What is wrong? My kernel version is 2.4.8. Is there
something wrong with the gcc compilier? My gcc
compilier is gcc-2.95.
Thanks to everyone. Your help is very beneficial to
me.
Michael
--- Tyler BIRD <[email protected]> wrote:
> Try this
>
> ?--------
>
> #define MODULE
>
> #include <linux/module.h>
> int init_module(void) { printk("<1>Hello World");
> return 0;}
> void cleanup_module(void) {printk("<1>Goodbye cruel
> world\n"); }
> ?---
>
> gcc -c -D__KERNEL__ hello.c
>
> compiled and loaded fine on my system
>
> I think linux/module.h defines
> the kernel version. Make sure that you have the
> kernel source headers installed under /usr/include
> which is a link to /usr/src/linux/include.
>
> you oughta put the above include/module.h at the
> begining of your source.
>
>
>
> Also there has been a macro lately to
> delate which routines will be init_module,
> cleanup_module22
>
> >>> Michael Zhu <[email protected]> 12/04/01 10:06AM
> >>>
> I've define these two when I compile the module. The
> command line is:
>
> gcc -D_KERNEL_ -DMODULE -c hello.c
>
>
> --- Tyler BIRD <[email protected]> wrote:
> > You need to define the __KERNEL__ and MODULE
> symbols
> >
> > #define __KERNEL__
> > #define MODULE
> >
> >
> > >>> Nav Mundi <[email protected]> 12/04/01
> 09:33AM
> > >>>
> > What are we doing wrong? - Nav & Michael
> > **************************************************
> >
> > hello.c Source:
> >
> > #include "/home/mzhu/linux/include/linux/config.h"
>
> > /*retrieve the CONFIG_* macros */
> > #if defined(CONFIG_MODVERSIONS) &&
> > !defined(MODVERSIONS)
> > #define MODVERSIONS /* force it on */
> > #endif
> >
> > #ifdef MODVERSIONS
> > #include
> > "/home/mzhu/linux/include/linux/modversions.h"
> > #endif
> >
> > #include "/home/mzhu/linux/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"); }
> >
> > Output:
> >
> > #>gcc -D_KERNEL_ -DMODULE -c hello.c
> >
> > [This builds the hello.o file. ]
> >
> > #>insmod hello.o
> >
> > hello.o : unresolved symbol printk
> > hello.o : Note: modules without a GPL compatible
> > license cannot use
> > GPONLY_symbols
> >
> >
> >
> >
> > -
> > To unsubscribe from this list: send the line
> > "unsubscribe linux-kernel" in
> > the body of a message to [email protected]
>
> > More majordomo info at
> > http://vger.kernel.org/majordomo-info.html
> > Please read the FAQ at http://www.tux.org/lkml/
> >
>
>
>
______________________________________________________
>
> Send your holiday cheer with
> http://greetings.yahoo.ca
>
______________________________________________________
Send your holiday cheer with http://greetings.yahoo.ca
in linux/module.h header file
KERNEL_VERSION is defined.
what you need to do is make sure the directory /usr/include is a link
to the include directory in your kernel source and not the header files os some other kernel.
if you cant do that try something like this
___NO_VERSION___
#include <linux/module.h>
KERNEL_VERSION(major,minor,release)
read more on this site
http://www.xml.com/ldd/chapter/book/ch02.html#t2
>>> Michael Zhu <[email protected]> 12/04/01 11:13AM >>>
I've changed my source file like this:
#define MODULE
#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"); }
And I use the following message to build the module.
But when I use insmod to load the module I got the
following error message:
hello.o : kernel-module version mismatch
hello.o was compiled for kernel version
2.4.12
while this kernel is version 2.4.8
What is wrong? My kernel version is 2.4.8. Is there
something wrong with the gcc compilier? My gcc
compilier is gcc-2.95.
Thanks to everyone. Your help is very beneficial to
me.
Michael
--- Christine Ames <[email protected]> wrote:
> > -----Original Message-----
> > From: Michael Zhu [mailto:[email protected]]
> > Sent: Tuesday, December 04, 2001 9:07 AM
>
> <snip>
>
> >
> >
> > I've define these two when I compile the module.
> The
> > command line is:
> >
> > gcc -D_KERNEL_ -DMODULE -c hello.c
> >
> >
> <snip>
> >
>
> See http://www.xml.com/ldd/chapter/book/ch02.html
>
> Where your source should be similar to:
>
> #define MODULE // <- HERE!!! define MODULE
> #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"); }
>
______________________________________________________
Send your holiday cheer with http://greetings.yahoo.ca
> I've changed my source file like this:
> #define MODULE
>
> #include <linux/module.h>
Is your kernel configured with module versioning ?
More important activities lacking, "Michael Zhu" <[email protected]> wrote:
> I've changed my source file like this:
> #define MODULE
>
> #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"); }
>
> And I use the following command line to build the
> module.
>
> gcc -c -D__KERNEL__ hello.c
>
> But when I use insmod to load the module I got the
> following error message:
>
> hello.o : kernel-module version mismatch
> hello.o was compiled for kernel version
> 2.4.12
> while this kernel is version 2.4.8
>
> What is wrong? My kernel version is 2.4.8. Is there
> something wrong with the gcc compilier? My gcc
> compilier is gcc-2.95.
You're not picking up the correct kernel header files. Don't allow GCC to pick
up the files from "/usr/include/linux":
$ gcc -I/usr/src/linux/include -c -D__KERNEL__ hello.c
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + -- -- -- -- -- -- -- -- -- --
Tommy Reynolds | mailto: <[email protected]>
Red Hat, Inc., Embedded Development Services | Phone: +1.256.704.9286
307 Wynn Drive NW, Huntsville, AL 35805 USA | FAX: +1.256.837.3839
Senior Software Developer | Mobile: +1.919.641.2923
Try this
?--------
#define MODULE
#include <linux/module.h>
int init_module(void) { printk("<1>Hello World"); return 0;}
void cleanup_module(void) {printk("<1>Goodbye cruel world\n"); }
?---
gcc -c -D__KERNEL__ hello.c
compiled and loaded fine on my system
I think linux/module.h defines
the kernel version. Make sure that you have the kernel source headers installed under /usr/include
which is a link to /usr/src/linux/include.
you oughta put the above include/module.h at the begining of your source.
Also there has been a macro lately to
delate which routines will be init_module, cleanup_module22
>>> Michael Zhu <[email protected]> 12/04/01 10:06AM >>>
I've define these two when I compile the module. The
command line is:
gcc -D_KERNEL_ -DMODULE -c hello.c
--- Tyler BIRD <[email protected]> wrote:
> You need to define the __KERNEL__ and MODULE symbols
>
> #define __KERNEL__
> #define MODULE
>
>
> >>> Nav Mundi <[email protected]> 12/04/01 09:33AM
> >>>
> What are we doing wrong? - Nav & Michael
> **************************************************
>
> hello.c Source:
>
> #include "/home/mzhu/linux/include/linux/config.h"
> /*retrieve the CONFIG_* macros */
> #if defined(CONFIG_MODVERSIONS) &&
> !defined(MODVERSIONS)
> #define MODVERSIONS /* force it on */
> #endif
>
> #ifdef MODVERSIONS
> #include
> "/home/mzhu/linux/include/linux/modversions.h"
> #endif
>
> #include "/home/mzhu/linux/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"); }
>
> Output:
>
> #>gcc -D_KERNEL_ -DMODULE -c hello.c
>
> [This builds the hello.o file. ]
>
> #>insmod hello.o
>
> hello.o : unresolved symbol printk
> hello.o : Note: modules without a GPL compatible
> license cannot use
> GPONLY_symbols
>
>
>
>
> -
> To unsubscribe from this list: send the line
> "unsubscribe linux-kernel" in
> the body of a message to [email protected]
> More majordomo info at
> http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
______________________________________________________
Send your holiday cheer with http://greetings.yahoo.ca