1
votes

I'm having some trouble with a C Makefile. It happens when I complile while opening the project file.

Here are the error:

[Warning] overriding recipe for target `DuLieuNganHang.o'

[Warning] ignoring old recipe for target `DuLieuNganHang.o'

g++.exe [Warning] linker input file unused because linking not done

g++.exe g++.exe D:\TinNC\MRT\g++.exe DuLieuNganHang.o: No such file or directory.

g++.exe g++.exe D:\TinNC\MRT\g++.exe DuLieuNganHang.o: No such file or directory.

D:\TinNC\MRT\Makefile.win [Error] [MRT.exe] Error 1

Here are the contents of the Makefile:

# Project: MRT
# Makefile created by Dev-C++ 5.3.0.4

CPP      = g++.exe -D__DEBUG__
CC       = gcc.exe -D__DEBUG__
WINDRES  = windres.exe
OBJ      = main.o MRT.o TaiKhoan.o Tien.o HoaDon.o GiaoDich.o NhatKyGiaoDichMRT.o DuLieuNganHang.o PhanCung.o DuLieuNganHang.o $(RES)
LINKOBJ  = main.o MRT.o TaiKhoan.o Tien.o HoaDon.o GiaoDich.o NhatKyGiaoDichMRT.o DuLieuNganHang.o PhanCung.o DuLieuNganHang.o $(RES)
LIBS     = -L"C:/Program Files (x86)/Dev-Cpp/MinGW64/x86_64-w64-mingw32/lib" -static-libgcc -g3
INCS     = -I"C:/Program Files (x86)/Dev-Cpp/MinGW64/x86_64-w64-mingw32/include"
CXXINCS  = -I"C:/Program Files (x86)/Dev-Cpp/MinGW64/x86_64-w64-mingw32/include"
BIN      = MRT.exe
CXXFLAGS = $(CXXINCS)  -g3
CFLAGS   = $(INCS)  -g3
RM       = rm -f

.PHONY: all all-before all-after clean clean-custom

all: all-before $(BIN) all-after


clean: clean-custom
${RM} $(OBJ) $(BIN)

$(BIN): $(OBJ)
$(CPP) $(LINKOBJ) -o $(BIN) $(LIBS)

main.o: main.cpp
$(CPP) -c main.cpp -o main.o $(CXXFLAGS)

MRT.o: MRT.cpp
$(CPP) -c MRT.cpp -o MRT.o $(CXXFLAGS)

TaiKhoan.o: TaiKhoan.cpp
$(CPP) -c TaiKhoan.cpp -o TaiKhoan.o $(CXXFLAGS)

Tien.o: Tien.cpp
$(CPP) -c Tien.cpp -o Tien.o $(CXXFLAGS)

HoaDon.o: HoaDon.cpp
$(CPP) -c HoaDon.cpp -o HoaDon.o $(CXXFLAGS)

GiaoDich.o: GiaoDich.cpp
$(CPP) -c GiaoDich.cpp -o GiaoDich.o $(CXXFLAGS)

NhatKyGiaoDichMRT.o: NhatKyGiaoDichMRT.cpp
$(CPP) -c NhatKyGiaoDichMRT.cpp -o NhatKyGiaoDichMRT.o $(CXXFLAGS)

DuLieuNganHang.o: DuLieuNganHang.cpp
$(CPP) -c DuLieuNganHang.cpp -o DuLieuNganHang.o $(CXXFLAGS)

PhanCung.o: PhanCung.cpp
$(CPP) -c PhanCung.cpp -o PhanCung.o $(CXXFLAGS)

DuLieuNganHang.o: DuLieuNganHang.txt
$(CPP) -c DuLieuNganHang.txt -o DuLieuNganHang.o $(CXXFLAGS)

Thank you!

1

1 Answers

0
votes

The answer is in your warnings:

[Warning] overriding recipe for target `DuLieuNganHang.o'

[Warning] ignoring old recipe for target `DuLieuNganHang.o'

This tells you that some point make is detecting a second recipe for how to build DuLieuNgangHang.o, and is ignoring the first recipe.

Looking at your makefile, the first rule says to build DuLieuNganHang.o from DuLieuNganHang.cpp. The second recipe says to build it from DuLieuNganHang.txt. Given that your error message says DuLieuNganHang.o does not exist, you probably don't have a file DuLieuNganHang.txt (otherwise I would expect a compiler error when it tries to parse a text file as a c++ file).

You should be able to correct your problem by deleting the second rule for DuLieuNganHang.o.