Reputation: 243
I get this error when using my makefile:
make: Warning: File `makefile' has modification time 56 s in the future
make: Circular Menu.o <- Menu.o dependency dropped.
g++ a.out main.o Menu.o CourseList.o Course.o LecturerList.o StudentList.o Lecturer.o Student.o -o a.out
make: warning: Clock skew detected. Your build may be incomplete.
This is my makefile:
a.out: main.o Menu.o CourseList.o Course.o LecturerList.o StudentList.o Lecturer.o Student.o
g++ main.o Menu.o CourseList.o Course.o LecturerList.o StudentList.o Lecturer.o Student.o -o a.out
main.o: main.cpp Lecturer.o LecturerList.o Student.o StudentList.o Course.o CourseList.o Menu.o
g++ -c main.cpp
Menu.o: Menu.o Lecturer.o LecturerList.o Student.o StudentList.o Course.o CourseList.o
g++ -c Menu.cpp
CourseList.o: CourseList.cpp
g++ -c CourseList.cpp
Course.o: Course.cpp
g++ -c Course.cpp
LecturerList.o: LecturerList.cpp
g++ -c LecturerList.cpp
StudentList.o: StudentList.cpp
g++ -c StudentList.cpp
Lecturer.o: Lecturer.cpp
g++ -c Lecturer.cpp
Student.o: Student.cpp
g++ -c Student.cpp
Where's the error and how do I fix it? I'm aware to the fact it might be alittle confusing, but I hope someone here can help me with this problem, I'm breaking my head over this for hours... Thanks!!
NOTE: I edited the error and the makefile. Now I have only 1 problem
Upvotes: 0
Views: 3149
Reputation: 168796
First, the problem with "File 'makefile' has modification time 56 s in the future" is a sysadmin problem. You are storing your files on a network file system. Your computer and the server computer don't agree on what time it is. To fix this, adjust the date on one or both of the computers so that they agree. To maintain that agreement, use something like "ntpd".
Second, the circular dependency is because you are confusing ".o" and ".cpp" files in your Makefile. Specifically, you are listing .o
files as source dependencies for other .o
files, which is (almost) never the case. Menu.o: Menu.o
is one such circular dependency.
Third, the "file a.out not found" message is because you are specifying "a.out" as both an input and output file on your linker command line.
Here is one fixed version of your Makefile (don't forget to fix up the tabs if you copy-paste this into your editor.)
a.out: main.o Menu.o CourseList.o Course.o LecturerList.o StudentList.o Lecturer.o Student.o
# Lose extraneous "a.out" on the next line.
g++ main.o Menu.o CourseList.o Course.o LecturerList.o StudentList.o Lecturer.o Student.o -o a.out
# Get rid of all '.o' in the next line. They don't make any sense.
main.o: main.cpp
g++ -c main.cpp
# Change "Menu.o" to "Menu.cpp" and get rid of other .o files
Menu.o: Menu.cpp
g++ -c Menu.cpp
CourseList.o: CourseList.cpp
g++ -c CourseList.cpp
Course.o: Course.cpp
g++ -c Course.cpp
LecturerList.o: LecturerList.cpp
g++ -c LecturerList.cpp
StudentList.o: StudentList.cpp
g++ -c StudentList.cpp
Lecturer.o: Lecturer.cpp
g++ -c Lecturer.cpp
Student.o: Student.cpp
g++ -c Student.cpp
Finally, your Makefile could be made much simpler and more readable if you were to use pattern rules and automatic variables.
Here is a much shorter version:
a.out: main.o Menu.o CourseList.o Course.o LecturerList.o StudentList.o Lecturer.o Student.o
g++ $^ -o a.out
# Take advantage of Makefile's pattern match to avoid specifying every. single. file.
%.o: %.cpp
g++ -c $<
Upvotes: 3
Reputation: 4829
The line
Menu.o: Menu.o Lecturer.o LecturerList.o Student.o StudentList.o Course.o CourseList.o
lists Menu.o
as a requisite of Menu.o
.
and a.out
as listed is an input to g++
you should use -o
to indicate that you want the output to go there.
Upvotes: 0
Reputation: 2491
I think you want
g++ -o a.out ...
not
g++ a.out ...
Also you can get rid of the circularity warning by not having Menu.o depend on Menu.o
Upvotes: 0
Reputation: 25808
The second line:
g++ a.out main.o Menu.o CourseList.o Course.o LecturerList.o StudentList.o Lecturer.o Student.o -o a.out
Is trying to compile a.out
into a.out
Upvotes: 0