Let me start by saying that I am a Windows 8 user on a HP laptop. So I very recently started an online course in c++ with 'c++ institute'. As recommended by them, I downloaded the MinGW/MSYS package, JDK and NetbBeans IDE version 8.0.2. I followed their installation instructions exactly (including updating the path directory by adding ";C:\\MinGW\\bin;C:\\MinGW\\MSYS\\1.0\\bin") I am now on chapter 3 of the program and everything was going ok until I tried to compile the following code (see below)
/*
* 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 %d\n",exp,pow);
pow = pow*2;
}
return 0;
}
For some reason when I try to compile and run the program I get the following error messages
"/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)
The code was copied and pasted directly from the course files and it seems to make sense to me. So can anybody tell me what I am doing wrong? Thanks in advance.
The relevant error message is
cannot open output file dist/Debug/MinGW-Windows/hello.exe: Permission denied
Which indicates you do not have write permission on the folder it's attempting to create hello.exe
in. Make the dist/Debug/MinGW-Windows
folder writable, and that error should be resolved.
https://netbeans.org/community/releases/80/cpp-setup-instructions.html#compilers_windows
Try by instructions given over here.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.