【发布时间】:2015-05-21 02:15:50
【问题描述】:
首先让我说我是 HP 笔记本电脑上的 Windows 8 用户。 因此,我最近在“c++ 学院”开始了 C++ 在线课程。按照他们的建议,我下载了 MinGW/MSYS 包、JDK 和 NetbBeans IDE 版本 8.0.2。 我完全按照他们的安装说明进行操作(包括通过添加“;C:\MinGW\bin;C:\MinGW\MSYS\1.0\bin”来更新路径目录) 我现在在程序的第 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 %d\n",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)
代码是直接从课程文件中复制和粘贴的,对我来说似乎很有意义。那么谁能告诉我我做错了什么?提前致谢。
【问题讨论】:
-
建议您在 Windows PATH 中包含
C:\MinGW\MSYS\1.0\bin的人应该立即挂起、绘制和划分。 唯一 认可的调用 MSYS 程序的方法是从由 msys.bat 脚本启动的 shell ...如果您愿意,可以通过桌面或开始菜单快捷方式。如果您坚持这种受支持的技术,则无需将其包含在 windows PATH 中;拥有它最终可能会导致悲伤。 -
谢谢。因此,如果我从路径中删除该目录,它会对问题进行排序,还是编译器需要进一步配置?抱歉,在编程方面我几乎是个菜鸟
-
不,我不认为在 Windows PATH 中有
C:\MinGW\MSYS\1.0\bin是您的问题的原因,在这种情况下,但它是配置错误。 MinGW.org 不支持尝试从尚未从正确实例化的 MSYS shell 启动的进程中运行 MSYS 程序,并且在某些阶段通常会导致奇怪的、可能是间歇性的故障。当您的进程从正确实例化的 MSYS shell 运行时,shell 初始化负责在 MSYS 环境中正确设置 PATH;在windows环境下设置是错误的。 -
@Phil 它是一直发生还是在您第一次打开程序时编译并运行良好但之后又失败了?
-
@PetrosDrakoulis 我已经放弃了这个设置。我现在正在使用 Borland、Notepad++ 和 Eclipse 开发一台新机器。抱歉,我不能再回答这个问题了
标签: c++ windows netbeans mingw