Reputation: 5
This is my makefile:
CC = g++
CFLAGS = -Wall -c
OBJS = report.o commandLine.o configuration.o tool.o project2demo.o
project2: $(OBJS)
$(CC) $(OBJS) -o project2
report.o: report.cpp report.h
$(CC) $(CFLAGS) report.cpp
commandLine.o: commandLine.cpp commandLine.h tool.h
$(CC) $(CFLAGS) commandLine.cpp
configuration.o: configuration.cpp configuration.h
$(CC) $(CFLAGS) configuration.cpp
tool.o: tool.cpp tool.h
$(CC) $(CFLAGS) tool.cpp
project2demo.o: tool.h project2demo.cpp
$(CC) $(CFLAGS) project2demo.cpp
clean:
rm *.o project2
And the error I am getting is:
file not recognized: File format not recognized collect2: ld returned 1 exit status
I can not figure out why this is. I looked at some similar topics, and the solutions did not work. For example, I tried deleting the object file that was not recognized (report.o) and rebuilding it. Any suggestions?
Thank you!
Edit: Full error as requested:
report.o: file not recognized: File format not recognized
collect2: ld returned 1 exit status
make: *** [project2] Error 1
Edit 2: I forgot to add that it works on windows. But when I connect to a linux machine using puTTy, I get this error.
Upvotes: 0
Views: 1633
Reputation: 17460
[...] it works on windows. But when I connect to a Linux machine using PuTTy, I get this error.
If you are using a shared file system, you need to call make clean
when switching between Windows and Linux.
Windows and Linux use different object file formats, and as such you can not use the object files of one OS on another. When using a shared file system, the make
will not automatically guess that the object files should be recompiled and would use the old files compiled under a different OS. That would result in the error you observed.
Upvotes: 1