Netbeans c++编译错误

Netbeans C++ Compiler Error

本文关键字:错误 编译 c++ Netbeans      更新时间:2023-10-16

让我先说一下,我是一台惠普笔记本电脑的Windows 8用户。所以我最近开始在"c++学院"上c++在线课程。按照他们的建议,我下载了MinGW/MSYS包、JDK和NetbBeans IDE版本8.0.2。我完全按照他们的安装说明(包括通过添加";C:MinGWbin;C:MinGWMSYS1.0bin"来更新路径目录)我现在在程序的第3章,一切都很正常,直到我试图编译以下代码(见下文)

/* 
 * File:   hello.cpp
 *
 * Created on 19 May 2015, 18:26
 */
#include <cstdlib>
#include <iostream>
#include <stdio.h>
int main(void) {
    int exp;
    int pow = 1;
    for(exp = 0; exp < 16; exp++) {
    printf("2 to the power of %d is %dn",exp,pow);
        pow = pow*2;
    }
    return 0;
}

由于某些原因,当我尝试编译并运行程序时,我得到以下错误消息

"/C/MinGW/MSYS/1.0/bin/make.exe" -f nbproject/Makefile-Debug.mk QMAKE=         SUBPROJECTS= .build-conf
make.exe[1]: Entering directory `/c/Users/Philip/Desktop/C++ Course/Hello'
"/C/MinGW/MSYS/1.0/bin/make.exe"  -f nbproject/Makefile-Debug.mk     dist/Debug/MinGW-Windows/hello.exe
make.exe[2]: Entering directory `/c/Users/Philip/Desktop/C++ Course/Hello'
mkdir -p build/Debug/MinGW-Windows
rm -f "build/Debug/MinGW-Windows/hello.o.d"
g++    -c -g -MMD -MP -MF "build/Debug/MinGW-Windows/hello.o.d" -o         build/Debug/MinGW-Windows/hello.o hello.cpp
mkdir -p dist/Debug/MinGW-Windows
g++     -o dist/Debug/MinGW-Windows/hello build/Debug/MinGW-Windows/hello.o 
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: cannot     open output file dist/Debug/MinGW-Windows/hello.exe: Permission denied
collect2.exe: error: ld returned 1 exit status
make.exe[2]: *** [dist/Debug/MinGW-Windows/hello.exe] Error 1
make.exe[2]: Leaving directory `/c/Users/Philip/Desktop/C++ Course/Hello'
make.exe[1]: *** [.build-conf] Error 2
make.exe[1]: Leaving directory `/c/Users/Philip/Desktop/C++ Course/Hello'
make.exe": *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 4s)

代码是直接从课程文件中复制和粘贴的,对我来说似乎是有意义的。有人能告诉我我哪里做错了吗?提前感谢。

相关的错误信息是

cannot open output file dist/Debug/MinGW-Windows/hello.exe: Permission denied

表示您没有试图在其中创建hello.exe的文件夹的写权限。使dist/Debug/MinGW-Windows文件夹可写,这个错误应该解决。

https://netbeans.org/community/releases/80/cpp-setup-instructions.html#compilers_windows

按这里给出的说明试试