Moin Moin!
Mit geht es aber eigentlich darum, warum das Einbinden der statischen Bibliothek zu falschen Ergebnissen führt?
Kann ich nicht nachvollziehen:
Makefile:
CFLAGS += -std=c99
default: clean test
clean:
rm -f *.o *.a allinone static
all: allinone static
allinone: allinone.o
allinone.o: allinone.c
allinone.c: durchschnitt.h durchschnitt.c Main.c
cat $^ > $@
static: Main.c libdurchschnitt.a
gcc -static durchschnitt.h Main.c -L. -ldurchschnitt -o static -std=c99
libdurchschnitt.a: durchschnitt.o
ar rcs libdurchschnitt.a durchschnitt.o
durchschnitt.o: durchschnitt.c
test: allinone static
for t in 3 5 "1 2 3" quark ""; do for f in $^ ; do echo "$$t | $$f" ; echo $$t | $$f ; done ; done
make:
rm -f *.o *.a allinone static
cc -std=c99 -c -o allinone.o allinone.c
cc allinone.o -o allinone
cc -std=c99 -c -o durchschnitt.o durchschnitt.c
ar rcs libdurchschnitt.a durchschnitt.o
gcc -static durchschnitt.h Main.c -L. -ldurchschnitt -o static -std=c99
for t in 3 5 "1 2 3" quark ""; do for f in allinone static ; do echo "$t | $f" ; echo $t | $f ; done ; done
3 | allinone
Zahl 1: 3.000000
Durchschnitt: 3.000000
3 | static
Zahl 1: 3.000000
Durchschnitt: 3.000000
5 | allinone
Zahl 1: 5.000000
Durchschnitt: 5.000000
5 | static
Zahl 1: 5.000000
Durchschnitt: 5.000000
1 2 3 | allinone
Zahl 1: 1.000000
Zahl 2: 2.000000
Zahl 3: 3.000000
Durchschnitt: 2.000000
1 2 3 | static
Zahl 1: 1.000000
Zahl 2: 2.000000
Zahl 3: 3.000000
Durchschnitt: 2.000000
quark | allinone
Zahl 1: 0.000000
Zahl 2: 0.000000
Zahl 3: 0.000000
Zahl 4: 0.000000
Zahl 5: 0.000000
Zahl 6: 0.000000
Durchschnitt: 0.000000
quark | static
Zahl 1: 0.000000
Zahl 2: 0.000000
Zahl 3: 0.000000
Zahl 4: 0.000000
Zahl 5: 0.000000
Zahl 6: 0.000000
Durchschnitt: 0.000000
| allinone
Zahl 1: 0.000000
Durchschnitt: 0.000000
| static
Zahl 1: 0.000000
Durchschnitt: 0.000000
gcc --version:
gcc (GCC) 4.2.3
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Alexander
--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so".
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so".