Reputation: 1187
I have this in my makefile
myfile: $(OBJECTS)
g++ -o $@ $^
This should convert into something like
g++ -o myfile XXX.o YYY.o ZZZ.o
But this generates different output in Windows and Linux
Windows: myfile.exe
Linux: myfile.out
So when I run make
again, it will rebuild (even if there's no changes), because the target name is myfile
and not myfile.exe
or myfile.out
. Of course I tried using myfile.exe
as target name on Windows, and it shows the up to date or nothing to do message I want.
How can I solve this problem so that Make finds myfile.exe|out
and decides to not rebuild it?
Upvotes: 1
Views: 67
Reputation: 21040
GCC on Windows will automatically append .exe to the output filename when linking, try something like
ifneq ($(findstring mingw,$(MAKE_HOST)),)
exe := .exe
endif
myfile$(exe): $(OBJECTS)
g++ -o $@ $^
Or as the comments say just use .exe for all platforms.
Upvotes: 3