I try to compile a simple c file in Dev-C++
and it shows an error on line 25 C:\Users\varun\Desktop\cprog\Makefile.win recipe for target 'Project1.exe' failed.
我尝试编译一个简单的c文件Dev-C + + 25 C:\Users\varun\Desktop\cprog\Makefile.,它显示了一个错误获取目标项目的配方。exe”失败了。
Makefile.win
Makefile.win
# Project: Project1
# Makefile created by Dev-C++ 5.6.2
CPP = g++.exe
CC = gcc.exe
WINDRES = windres.exe
OBJ = main.o Untitled2.o
LINKOBJ = main.o Untitled2.o
LIBS = -L"C:/Program Files (x86)/Dev-Cpp/MinGW64/lib" -L"C:/Program Files (x86)/Dev-Cpp/MinGW64/x86_64-w64-mingw32/lib" -static-libgcc
INCS = -I"C:/Program Files (x86)/Dev-Cpp/MinGW64/include" -I"C:/Program Files (x86)/Dev-Cpp/MinGW64/x86_64-w64-mingw32/include" -I"C:/Program Files (x86)/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.8.1/include"
CXXINCS = -I"C:/Program Files (x86)/Dev-Cpp/MinGW64/include" -I"C:/Program Files (x86)/Dev-Cpp/MinGW64/x86_64-w64-mingw32/include" -I"C:/Program Files (x86)/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.8.1/include" -I"C:/Program Files (x86)/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.8.1/include/c++"
BIN = Project1.exe
CXXFLAGS = $(CXXINCS)
CFLAGS = $(INCS)
RM = rm.exe -f
.PHONY: all all-before all-after clean clean-custom
all: all-before $(BIN) all-after
clean: clean-custom
${RM} $(OBJ) $(BIN)
$(BIN): $(OBJ)
**$(CC) $(LINKOBJ) -o $(BIN) $(LIBS)**
main.o: main.c
$(CC) -c main.c -o main.o $(CFLAGS)
Untitled2.o: Untitled2.c
$(CC) -c Untitled2.c -o Untitled2.o $(CFLAGS)
Errors
错误
C:\Users\varun\Desktop\cprog\Untitled2.o Untitled2.c:(.text+0x0): multiple definition of `main'
C:\Users\varun\Desktop\cprog\main.o main.c:(.text+0x0): first defined here
C:\Users\varun\Desktop\cprog\collect2.exe [Error] ld returned 1 exit status
25 C:\Users\varun\Desktop\cprog\Makefile.win recipe for target 'Project1.exe' failed
1 个解决方案
#1
4
The important bit of the output is:
输出的重要部分是:
C:\Users\varun\Desktop\cprog\Untitled2.o Untitled2.c:(.text+0x0): multiple definition of `main'
It tells you, that you have two definitions of function main
. You need exactly one such definition in an executable. The next line of the error tells you, where that definition is:
它告诉你,函数main有两个定义。您需要在可执行文件中精确地定义一个这样的定义。误差的下一行告诉你,这个定义是:
C:\Users\varun\Desktop\cprog\main.o main.c:(.text+0x0): first defined here
So you have function main
defined in Untitled2.c
and you have another function main
defined in main.c
. Delete one of them. From the names perhaps the main.c
is unnecessary altogether, but I can't tell without seeing the files.
所以你有函数main在Untitled2中定义。c还有一个main。c中定义的函数。删除其中的一个。从名字也许是主要的。c完全没有必要,但是我看不清楚文件。
#1
4
The important bit of the output is:
输出的重要部分是:
C:\Users\varun\Desktop\cprog\Untitled2.o Untitled2.c:(.text+0x0): multiple definition of `main'
It tells you, that you have two definitions of function main
. You need exactly one such definition in an executable. The next line of the error tells you, where that definition is:
它告诉你,函数main有两个定义。您需要在可执行文件中精确地定义一个这样的定义。误差的下一行告诉你,这个定义是:
C:\Users\varun\Desktop\cprog\main.o main.c:(.text+0x0): first defined here
So you have function main
defined in Untitled2.c
and you have another function main
defined in main.c
. Delete one of them. From the names perhaps the main.c
is unnecessary altogether, but I can't tell without seeing the files.
所以你有函数main在Untitled2中定义。c还有一个main。c中定义的函数。删除其中的一个。从名字也许是主要的。c完全没有必要,但是我看不清楚文件。