netbeans c程序构建失败,使用tdm-gcc msys

时间:2017-01-13 13:55:51

标签: c netbeans msys build-error tdm-gcc

我最近开始使用netbeans来编程。我通常使用代码块。为此,我安装了tdm-gcc和msys。

程序正在成功编译。但在执行时,它显示构建失败(退出值2)。

    "/C/msys/1.0/bin/make.exe" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make.exe[1]: Entering directory `/f/NetBeansProjects/C_Programs'
"/C/msys/1.0/bin/make.exe"  -f nbproject/Makefile-Debug.mk dist/Debug/MinGW_TDM-Windows/c_programs.exe
make.exe[2]: Entering directory `/f/NetBeansProjects/C_Programs'
mkdir -p build/Debug/MinGW_TDM-Windows
rm -f "build/Debug/MinGW_TDM-Windows/main.o.d"
gcc    -c -g -MMD -MP -MF "build/Debug/MinGW_TDM-Windows/main.o.d" -o build/Debug/MinGW_TDM-Windows/main.o main.c
mkdir -p dist/Debug/MinGW_TDM-Windows
gcc     -o dist/Debug/MinGW_TDM-Windows/c_programs build/Debug/MinGW_TDM-Windows/main.o build/Debug/MinGW_TDM-Windows/structure_union.o 
build/Debug/MinGW_TDM-Windows/structure_union.o: In function `main':
F:\NetBeansProjects\C_Programs/structure_union.c:32: multiple definition of `main'
build/Debug/MinGW_TDM-Windows/main.o:F:\NetBeansProjects\C_Programs/main.c:15: first defined here
collect2.exe: error: ld returned 1 exit status
make.exe[2]: *** [dist/Debug/MinGW_TDM-Windows/c_programs.exe] Error 1
make.exe[2]: Leaving directory `/f/NetBeansProjects/C_Programs'
make.exe[1]: *** [.build-conf] Error 2
make.exe[1]: Leaving directory `/f/NetBeansProjects/C_Programs'
make.exe": *** [.build-impl] Error 2

BUILD FAILED (exit value 2, total time: 657ms)

有人能帮助我做错吗?

1 个答案:

答案 0 :(得分:0)

您的项目中有多个main()函数:

  

[...] /structure_union.c:32: `main' 的多重定义

似乎structure_union中有一个,main.c中有另一个(第15行)。

C仅允许main() 一个定义 ;删除其中一个,它应该工作。