Linkerproblem with mcal/datetime.h

T

Thomas

Hi everybody,
I haven't found any fitting previous question/answer,
so I need to bother you.

I can't figure out where the problem lies therefor I
post the entire code of my program, followed by the
error output of gcc:

#include <mcal/datetime.h>
#include <stdio.h>

int main( int argc, char **argv )       {
  int y = 1980,
      m = 9,
      t = 28,
      doy;
  struct datetime *date;

  dt_now(date);
  doy = dt_dayofyear(date);
  dt_setdate(date,y,m,t );
  if(dt_dayofyear(datum) == (doy+2))    {
                printf("2 days left");
        }
}

erroroutput:

/tmp/ccoaguJ2.o(.text+0x2c): In function `main':
: undefined reference to `dt_now'
/tmp/ccoaguJ2.o(.text+0x3a): In function `main':
: undefined reference to `dt_dayofyear'
/tmp/ccoaguJ2.o(.text+0x51): In function `main':
: undefined reference to `dt_setdate'
/tmp/ccoaguJ2.o(.text+0x5f): In function `main':
: undefined reference to `dt_dayofyear'
collect2: ld returned 1 exit status

Can anybody explain me why this errors occur?

I've looked in time.h, but this struct doesn't
seem to be helpfull for comparing dates; Are there
any other usefull structs I could use?
 
M

Mark A. Odell

Thomas said:
Hi everybody,
I haven't found any fitting previous question/answer,
so I need to bother you.

I can't figure out where the problem lies therefor I
post the entire code of my program, followed by the
error output of gcc:

#include <mcal/datetime.h>
This header is not part of ISC C.
#include <stdio.h>

int main( int argc, char **argv )       {
  int y = 1980,
      m = 9,
      t = 28,
      doy;
  struct datetime *date;

  dt_now(date);
  doy = dt_dayofyear(date);
  dt_setdate(date,y,m,t );
  if(dt_dayofyear(datum) == (doy+2))    {
                printf("2 days left");
        }
Nasty indenting!
}

erroroutput:

/tmp/ccoaguJ2.o(.text+0x2c): In function `main':
: undefined reference to `dt_now'
/tmp/ccoaguJ2.o(.text+0x3a): In function `main':
: undefined reference to `dt_dayofyear'
/tmp/ccoaguJ2.o(.text+0x51): In function `main':
: undefined reference to `dt_setdate'
/tmp/ccoaguJ2.o(.text+0x5f): In function `main':
: undefined reference to `dt_dayofyear'
collect2: ld returned 1 exit status

Can anybody explain me why this errors occur?

It says exactly what's happening. The linker cannot find the
implementation of the non-ISO C functions listed. Including a header file
only tells the compiler what the function signatures look like. The actual
implementation of the functions is usually in a library or object file. We
can't help you with that here in comp.lang.c.

By the way, why post to comp.lang.c then truncate it from the followup
list?
 
P

Peter Shaggy Haywood

Groovy hepcat Thomas was jivin' on Thu, 14 Oct 2004 20:29:58 +0200 in
comp.lang.c.
Linkerproblem with mcal/datetime.h's a cool scene! Dig it!
I can't figure out where the problem lies therefor I
post the entire code of my program, followed by the
error output of gcc:

#include <mcal/datetime.h>

Non-standard header.
#include <stdio.h>

int main( int argc, char **argv )       {

Unused parameters. What's wrong with the simpler "int main(void)"?
  int y = 1980,
      m = 9,
      t = 28,
      doy;
  struct datetime *date;

Type struct datetime either undefined or defined in non-standard
header.
  dt_now(date);

Function dt_now() either undeclared or declared in non-standard
header.
  doy = dt_dayofyear(date);

Function dt_dayofyear() either undeclared or declared in
non-standard header.
  dt_setdate(date,y,m,t );

Function dt_setdate() either undeclared or declared in non-standard
header.
  if(dt_dayofyear(datum) == (doy+2))    {


Function dt_dayofyear() either undeclared or declared in
non-standard header. Variable or macro datum either undeclared or
declared in non-standard header.
                printf("2 days left");
        }

No return statement. This is OK in C99 (for main() only), though
still not adviseable. It is an error in C90.
}

erroroutput:

/tmp/ccoaguJ2.o(.text+0x2c): In function `main':
: undefined reference to `dt_now'
/tmp/ccoaguJ2.o(.text+0x3a): In function `main':
: undefined reference to `dt_dayofyear'
/tmp/ccoaguJ2.o(.text+0x51): In function `main':
: undefined reference to `dt_setdate'
/tmp/ccoaguJ2.o(.text+0x5f): In function `main':
: undefined reference to `dt_dayofyear'
collect2: ld returned 1 exit status

Can anybody explain me why this errors occur?

You didn't link in whatever library provides those functions, maybe?
I've looked in time.h, but this struct doesn't

What struct? You mean struct tm?
seem to be helpfull for comparing dates; Are there
any other usefull structs I could use?

For what? It's not entirely clear what you are trying to do.

--

Dig the even newer still, yet more improved, sig!

http://alphalink.com.au/~phaywood/
"Ain't I'm a dog?" - Ronny Self, Ain't I'm a Dog, written by G. Sherry & W. Walker.
I know it's not "technically correct" English; but since when was rock & roll "technically correct"?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,147
Messages
2,570,835
Members
47,383
Latest member
EzraGiffor

Latest Threads

Top