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):
main.c:
date.c:
date.h
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
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: