gpt4 book ai didi

c++ - 收到 BUILD_FAIL 错误

转载 作者:塔克拉玛干 更新时间:2023-11-03 07:58:27 24 4
gpt4 key购买 nike

我在 ubuntu 上使用 netbeans IDE for c++,每当我运行一个程序时,我都会收到 BUILD_FAIL 错误

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

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

我正在运行一个简单的程序来打印 hello world。

最佳答案

从编译器吐出的内容来看,您似乎有两个文件指定 main() 作为一个项目构建。

/home/rupesh/NetBeansProjects/Cpp1/1.cpp:4: multiple definition of `main'

build/Debug/GNU-Linux-x86/main.o:/home/rupesh/NetBeansProjects/Cpp1/main.cpp:15:

first defined here collect2: ld returned 1 exit status make[2]: *

[dist/Debug/GNU-Linux-x86/cpp1] Error 1

检查您的文件夹以确保您没有编译器试图使用 main.cpp 构建的其他文件,在本例中查找 1.cpp

关于c++ - 收到 BUILD_FAIL 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14024354/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com