undefined reference

undefined reference

Post by Joseph A. Knapk » Sun, 18 Mar 2001 06:45:30





> > First time with Linux
> > RedHat 6.1 (2.2.12-20)

> > I try to compile this very simple program:
> > -------------------------------------------
> > $ cat myprog.c
> > #include <stdio.h>
> > #include <linux/timer.h>
> > struct timer_list timer;
> > main ()
> > {
> >    init_timer (&timer);
> > }
> > -------------------------------------------
> > $ gcc -o myprog myprog.c
> > /tmp/ccVmyTBJ.o: In function `main':
> > /tmp/ccVmyTBJ.o(.text+0x9): undefined reference to `init_timer'
> > collect2: ld returned 1 exit status
> > -------------------------------------------
> > I don't know why I got this error message, I included the
> > needed header file

> > [snip /usr/include/linux/timer.h]
> > extern inline void init_timer(struct timer_list * timer)
> > {
> >    timer->next = NULL;
> >    timer->prev = NULL;
> > }

> > What I have to do with extern function in header file?

> > I also taught it was about library.  With "nm", I looked for
> > "init_timer" in all object files under /usr/lib/lib*.a (and
> > recursively too), but I can't find any.

> > Where is the archive mailing list of this newsgroup?

> > Please help me to enjoy my introduction to Linux

> > Omer

> H'm...  my version of the header has it declared as "static inline".
>                                                      ^^^^^^

And aside from that, calling private internal kernel functions
from user-space code is unlikely to ever work :-) There is no
userspace library you could link to get the kernel timer
functions, because... well, they're in the kernel.

Possibly you want to look at the time-related functions in the
C standard library. man time, man signal, man 7 signal (look
for SIGALRM), and read the "settimer" thread in this newsgroup
over the past couple of days.

-- Joe Knapka
"It was just a maddened crocodile hidden in a flower bed. It could
 have happened to anyone." -- Pratchett
// Linux MM Documentation in progress:
// http://home.earthlink.net/~jknapka/linux-mm/vmoutline.html
* Evolution is an "unproven theory" in the same sense that gravity is. *

 
 
 

undefined reference

Post by Micah Cowa » Sun, 18 Mar 2001 05:47:26



> First time with Linux
> RedHat 6.1 (2.2.12-20)

> I try to compile this very simple program:
> -------------------------------------------
> $ cat myprog.c
> #include <stdio.h>
> #include <linux/timer.h>
> struct timer_list timer;
> main ()
> {
>    init_timer (&timer);
> }
> -------------------------------------------
> $ gcc -o myprog myprog.c
> /tmp/ccVmyTBJ.o: In function `main':
> /tmp/ccVmyTBJ.o(.text+0x9): undefined reference to `init_timer'
> collect2: ld returned 1 exit status
> -------------------------------------------
> I don't know why I got this error message, I included the
> needed header file

> [snip /usr/include/linux/timer.h]
> extern inline void init_timer(struct timer_list * timer)
> {
>    timer->next = NULL;
>    timer->prev = NULL;
> }

> What I have to do with extern function in header file?

> I also taught it was about library.  With "nm", I looked for
> "init_timer" in all object files under /usr/lib/lib*.a (and
> recursively too), but I can't find any.

> Where is the archive mailing list of this newsgroup?

> Please help me to enjoy my introduction to Linux

> Omer

H'm...  my version of the header has it declared as "static inline".
                                                     ^^^^^^

I have no idea what would be meant by "extern inline"; but if I were
you I'd be strongly tempted to change the declaration to the way mine
has it - but if you do that, save a copy first (it's not wise to
frivolously tamper with system headers...)

Micah

 
 
 

undefined reference

Post by omer » Sat, 17 Mar 2001 23:03:58


First time with Linux
RedHat 6.1 (2.2.12-20)

I try to compile this very simple program:
-------------------------------------------
$ cat myprog.c
#include <stdio.h>
#include <linux/timer.h>
struct timer_list timer;
main ()
{
   init_timer (&timer);

Quote:}

-------------------------------------------
$ gcc -o myprog myprog.c
/tmp/ccVmyTBJ.o: In function `main':
/tmp/ccVmyTBJ.o(.text+0x9): undefined reference to `init_timer'
collect2: ld returned 1 exit status
-------------------------------------------
I don't know why I got this error message, I included the
needed header file

[snip /usr/include/linux/timer.h]
extern inline void init_timer(struct timer_list * timer)
{
   timer->next = NULL;
   timer->prev = NULL;

Quote:}

What I have to do with extern function in header file?

I also taught it was about library.  With "nm", I looked for
"init_timer" in all object files under /usr/lib/lib*.a (and
recursively too), but I can't find any.

Where is the archive mailing list of this newsgroup?

Please help me to enjoy my introduction to Linux

Omer