Ich kann nicht herausfinden, warum mein Makefile nicht ordnungsgemäß ausgeführt wird. Ich bin die folgenden Fehler bekommen:Makefile C Linux FEHLER
gcc hr_timer.c -o hr
gcc hr_timer.o -o hr_timer
gcc: error: hr_timer.o: No such file or directory
gcc: fatal error: no input files
compilation terminated.
make: *** [hr_timer] Error 4
Hier ist mein Make-Datei:
CC = gcc
CFLAGS = -pthread
all: hr_timer q2q3 process_switching thread_switching
hr_timer.o: hr_timer.c
$(CC) hr_timer.c -o hr
q2q3.o: q2q3.c
$(CC) q2q3.c -o qq
process_switching.o: process_switching.c
$(CC) process_switching.c -o pr
thread_switching.o: thread_switching.c
$(CC) thread_switching.c -o th
und hier ist das Verzeichnis, das es in ist:
Alle .c Dateien kompilieren sehr gut ohne die Makefile. Vielen Dank!
EDIT:
neue Make-Datei:
CC = gcc
CFLAGS = -pthread
all: hr_timer q2q3 process_switching thread_switching
hr_timer.o: hr_timer.c
$(CC) hr_timer.c -o hr hr_timer.o
q2q3.o: q2q3.c
$(CC) q2q3.c -o qq q2q3.o
process_switching.o: process_switching.c
$(CC) process_switching.c -o pr process_switching.o
thread_switching.o: thread_switching.c
$(CC) $(CFLAGS) thread_switching.c -o th thread_switching.o
ERROR:
gcc hr_timer.c -o hr hr_timer.o
gcc: error: hr_timer.o: No such file or directory
make: *** [hr_timer.o] Error 1
EDIT2 (FIX):
CC = gcc
CFLAGS = -pthread
all: hr qq pr th
hr: hr_timer.c
$(CC) hr_timer.c -o hr
qq: q2q3.c
$(CC) q2q3.c -o qq
pr: process_switching.c
$(CC) process_switching.c -o pr
th: thread_switching.c
$(CC) $(CFLAGS) thread_switching.c -o th
Danke für die Antwort. Ich habe die Änderungen vorgenommen, die Sie erwähnt haben, aber ich bekomme immer noch einen Fehler. Bitte überprüfen Sie die Bearbeitung. – user5056973
Es sollte nicht '-o hr hr_timer.o' sein. Es sollte nur '-o hr_timer.o' sein, das besagt, dass die Ausgabe in die Datei hr_timer.o erfolgen soll. Keine Notwendigkeit für eine Stunde in der Mitte. Lesen Sie sorgfältig –
Danke. Es funktioniert jetzt. – user5056973