无法在Netbeans中编译单个C ++文件,但能够构建完整的项目

时间:2018-01-24 01:41:40

标签: c++ c++11 netbeans-8

当我右键单击并尝试编译文件时,我在Netbeans中遇到单文件编译问题。我还遇到了“ Netbeans: cannot find include file <iostream>, also, unable to resolve identifier std, cout ”中提到的其他问题并解决了所有其他问题。构建工作正常,但只有编译问题。

编译错误:

cd 'C:\Study Materials\C++\CPP Programs MP Compiled\Projects\collegeProject\collegeProject'
C:\MinGW\MSYS 1.0\bin\make.exe -f nbproject/Makefile-Debug.mk build/Debug/MinGW-Windows/FileHandling.o
Cannot run program "C:\MinGW\MSYS" (in directory "C:\Study Materials\C++\CPP Programs MP Compiled\Projects\collegeProject\collegeProject"): CreateProcess error=2, The system cannot find the file specified

构建日志(仅部分):

cd 'C:\Study Materials\C++\CPP Programs MP Compiled\Projects\collegeProject\collegeProject'
C:\MinGW\MSYS 1.0\bin\make.exe -f Makefile CONF=Debug
"/C/MinGW/MSYS 1.0/bin/make.exe" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make.exe[1]: Entering directory `/c/Study Materials/C++/CPP Programs MP Compiled/Projects/collegeProject/collegeProject'
"/C/MinGW/MSYS 1.0/bin/make.exe"  -f nbproject/Makefile-Debug.mk dist/Debug/MinGW-Windows/collegeproject.exe
make.exe[2]: Entering directory `/c/Study Materials/C++/CPP Programs MP Compiled/Projects/collegeProject/collegeProject'
mkdir -p build/Debug/MinGW-Windows
rm -f "build/Debug/MinGW-Windows/FileHandling.o.d"
g++    -c -g -std=c++11 -MMD -MP -MF "build/Debug/MinGW-Windows/FileHandling.o.d" -o build/Debug/MinGW-Windows/FileHandling.o FileHandling.cpp
mkdir -p build/Debug/MinGW-Windows
rm -f "build/Debug/MinGW-Windows/admin.o.d"
.
.
.

mkdir -p dist/Debug/MinGW-Windows
g++     -o dist/Debug/MinGW-Windows/collegeproject build/Debug/MinGW-Windows/FileHandling.o build/Debug/MinGW-Windows/admin.o build/Debug/MinGW-Windows/login.o build/Debug/MinGW-Windows/main.o build/Debug/MinGW-Windows/person.o build/Debug/MinGW-Windows/staff.o build/Debug/MinGW-Windows/student.o build/Debug/MinGW-Windows/subjects.o build/Debug/MinGW-Windows/utilities.o 
make.exe[2]: Leaving directory `/c/Study Materials/C++/CPP Programs MP Compiled/Projects/collegeProject/collegeProject'
make.exe[1]: Leaving directory `/c/Study Materials/C++/CPP Programs MP Compiled/Projects/collegeProject/collegeProject'

BUILD SUCCESSFUL (total time: 8s)

1 个答案:

答案 0 :(得分:1)

问题是MinGW路径中的空间“C:\ MinGW \ MSYS”只是路径“C:\ MinGW \ MSYS 1.0。的一部分。确保路径中没有空格安装MinGW和MSYS的位置。

  

mingw.org/wiki/Getting_Started

     

MinGW安装说明

     

MinGW可能存在包含空格的路径问题,如果没有,   通常与MinGW一起使用的其他程序会遇到问题   这样的路径。因此, 强烈建议 不安装MinGW   在路径名称引用中包含空格的任何位置 。你应该   避免安装到任何名称相似的目录或子目录中   “程序文件”或“我的文档”等

另见Netbeans and MinGW-w64