undefined reference to

hintermair

Grünschnabel
Hallo,

soll fürs studium was in c erarbeiten, um c kennenzulernen

leider bekomme ich immer "undefined reference to" wenn ich make aufrufe

makefile (vom prof bekommen):
Code:
objects = main.o complex.o date.o
libobj = complex.o date.o
all: libio.a main
main: main.o libio.a
	gcc -Wall -o main main.o -L -lio
main.o: date.h complex.h
	gcc -Wall -c main.c
complex.o:
	gcc -Wall -c complex.c
date.o:
	gcc -Wall -c date.c
libio.a: $(libobj)
	ar rs libio.a $(libobj)
clean:
	rm -f libio.a main.exe main.o $(libobj)

main.c:
Code:
#include <stdio.h>
#include "date.h"
#include "complex.h"

int main ()
{  date datum;
   complex komplex;

   for(;;)
   {  printf("Beispiel 26.4.2009)\nBitte eingeben: ");
      read_date(stdin, &datum);
      printf("\n");
      printf("Beispiel (1.234, 3.21)\nBitte eingeben: ");
      read_complex(stdin, &komplex);
      print_date(stdout, &datum);
      printf("\n");
      print_complex(stdout, &komplex);
      printf("\n\n");
   }
}

date.c:
Code:
#include <stdio.h>
#include "date.h"

void read_date(FILE *file, date *d)
{  char line[100];

   fgets(line, sizeof(line), file);
   sscanf(line, "%d.%d.%d", &d->day, &d->month, &d->year);
}

void print_date(FILE *file, date *d)
{  fprintf(file, "%02d.%02d.%04d", d->day, d->month, d->year);
}

date.h
Code:
#ifndef DATE_H
#define DATE_H

#include <stdio.h>

struct date
{  int year;
   int month;
   int day;
};

typedef struct date date;

extern void read_date(FILE *file, date *d);
extern void print_date(FILE *file, date *d);

#endif

complex.c und complex.h haben grundsaetzlich den selben aufbau wie die date-dateien.
------------------------------------------------------------

ich aergere mich jetzt schon ein paar tage damit rum und komme nicht weiter.
deswegen hoffe ich jemand kann mir sagen was ich falsch gemacht habe.
danke schonmal im vorraus fuer jegliche muehe
 
Zuletzt bearbeitet:
Hi.

Und die vollständige Fehlermeldung wäre noch wichtig.

Und bitte bearbeite deinen Beitrag hinsichtlich des Hinweises von 3Cyb3r. Für den Makefile Code kannst du einfach [code]...[/code] verwenden.

Gruß
 
ich geb mal alles an

Code:
$ make
gcc -Wall -c complex.c
gcc -Wall -c date.c
ar rs libio.a complex.o date.o
ar: creating libio.a
gcc -Wall -c main.c
gcc -Wall -o main main.o -L -lio
main.o:main.c:(.text+0x4b): undefined reference to '_read_date'
main.o:main.c:(.text+0x7c): undefined reference to '_read_complex'
main.o:main.c:(.text+0x95): undefined reference to '_print_date'
main.o:main.c:(.text+0xba): undefined reference to '_print_complex'
collect2: ld returned 1 exit status
make: *** [main] Error 1
 
Zurück