|
Home > Archive > alt.os.linux > August 2002 > Problem while compiling simple program
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Problem while compiling simple program
|
|
| Markus Falkensteiner 2002-08-27, 2:29 pm |
| Hello,
i have a little C++ Program which i can't compile, because i always get
following
error.
implicit declaration of function 'int printk(...)'
*************
my code is the following:
#define MODULE
#include <linux/module.h>
#include <linux/kernel.h>
int init_module(void) {
printk("<0>***Hello World from module***\n");
return 0;
}
void cleanup_module(void) {
printk("<0>*** Good Bye from Module ***\n");
}
******************
My kernel-sources are installed.
Makefile is: gcc test_treiber.cpp -o treiber
I'm using SUSE7.3
Does anybody has an idea, what's wrong with my settings.
Thx for any comment,
Markus
| |
| Peter T. Breuer 2002-08-27, 2:29 pm |
| Markus Falkensteiner <falkm@gmx.net> wrote:
> i have a little C++ Program which i can't compile, because i always get
> following
> error.
> implicit declaration of function 'int printk(...)'
printk doesn't exist. It's not a C (C++) library function, a
and it's not declared in any C or C++ include header.
Nevertheless that shouldn't be fatal. The fatal problem is that it won't
link! There's no such function in any library.
> #define MODULE
> #include <linux/module.h>
> #include <linux/kernel.h>
This is kernel code. You can't write that in C++! Well, YOU can't.
Peter
| |
| R Smith 2002-08-27, 9:29 pm |
| On Tue, 27 Aug 2002 14:33:49 -0400, Markus Falkensteiner wrote:
> Hello,
>
> i have a little C++ Program which i can't compile, because i always get
> following
> error.
>
> implicit declaration of function 'int printk(...)'
....
> Thx for any comment,
>
> Markus
$ gcc -c test_treiber.cpp
$ insmod ./test_treiber.o
| |
| R Smith 2002-08-27, 10:29 pm |
| On Tue, 27 Aug 2002 14:33:49 -0400, Markus Falkensteiner wrote:
> Hello,
>
> i have a little C++ Program which i can't compile, because i always get
> following
> error.
>
> implicit declaration of function 'int printk(...)'
....
> Thx for any comment,
>
> Markus
$ gcc -c test_treiber.cpp
$ insmod ./test_treiber.o
| |
| R Smith 2002-08-28, 3:28 pm |
| On Tue, 27 Aug 2002 23:02:18 -0400, R Smith wrote:
> On Tue, 27 Aug 2002 14:33:49 -0400, Markus Falkensteiner wrote:
>
>> Hello,
>>
>> i have a little C++ Program which i can't compile, because i always get
>> following
>> error.
>>
>> implicit declaration of function 'int printk(...)'
> ...
>> Thx for any comment,
>>
>> Markus
>
> $ gcc -c test_treiber.cpp
> $ insmod ./test_treiber.o
Oops, that should be a '.c' suffix to keep gcc happy. And I have to
specify an include path to get it right.
$ gcc -c mymod.c -I/usr/src/linux-2.4.18/include
otherwise it compiles for the wrong kernel version.
---
'Good luck guys,' chirped the computer,
'impact minux thirty seconds...'
Douglas Adams
| |
| R Smith 2002-08-28, 4:29 pm |
| On Tue, 27 Aug 2002 23:02:18 -0400, R Smith wrote:
> On Tue, 27 Aug 2002 14:33:49 -0400, Markus Falkensteiner wrote:
>
>> Hello,
>>
>> i have a little C++ Program which i can't compile, because i always get
>> following
>> error.
>>
>> implicit declaration of function 'int printk(...)'
> ...
>> Thx for any comment,
>>
>> Markus
>
> $ gcc -c test_treiber.cpp
> $ insmod ./test_treiber.o
Oops, that should be a '.c' suffix to keep gcc happy. And I have to
specify an include path to get it right.
$ gcc -c mymod.c -I/usr/src/linux-2.4.18/include
otherwise it compiles for the wrong kernel version.
---
'Good luck guys,' chirped the computer,
'impact minux thirty seconds...'
Douglas Adams
|
|
|
|
|