在netbeans中构建和运行简单的c ++程序时出错

时间:2015-08-28 18:27:58

标签: ubuntu netbeans g++

错误:

"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory `/home/mohammad/NetBeansProjects/CppApplication_1'
"/usr/bin/make"  -f nbproject/Makefile-Debug.mk dist/Debug/GNU-Linux-x86/cppapplication_1
make[2]: Entering directory `/home/mohammad/NetBeansProjects/CppApplication_1'
mkdir -p dist/Debug/GNU-Linux-x86
g++     -o dist/Debug/GNU-Linux-x86/cppapplication_1 build/Debug/GNU-Linux-x86/main.o build/Debug/GNU-Linux-x86/newfile.o build/Debug/GNU-Linux-x86/newmain.o 
build/Debug/GNU-Linux-x86/newfile.o: In function `main':
/home/mohammad/NetBeansProjects/CppApplication_1/newfile.cpp:5: multiple definition of `main'
build/Debug/GNU-Linux-x86/main.o:/home/mohammad/NetBeansProjects/CppApplication_1/main.cpp:15: first defined here
build/Debug/GNU-Linux-x86/newmain.o: In function `main':
/home/mohammad/NetBeansProjects/CppApplication_1/newmain.c:14: multiple definition of `main'
build/Debug/GNU-Linux-x86/main.o:/home/mohammad/NetBeansProjects/CppApplication_1/main.cpp:15: first defined here
collect2: error: ld returned 1 exit status
make[2]: *** [dist/Debug/GNU-Linux-x86/cppapplication_1] Error 1
make[2]: Leaving directory `/home/mohammad/NetBeansProjects/CppApplication_1'
make[1]: *** [.build-conf] Error 2
make[1]: Leaving directory `/home/mohammad/NetBeansProjects/CppApplication_1'
make: *** [.build-impl] Error 2

BUILD FAILED(退出值2,总时间:168ms)

1 个答案:

答案 0 :(得分:0)

两个C ++源文件有一个main方法:main.cpp和newfile.cpp

从项目中删除其中一个文件或重命名其中的main方法。