【问题标题】:Unable to compile single C++ file in Netbeans, but able to build full project无法在 Netbeans 中编译单个 C++ 文件,但能够构建完整项目
【发布时间】:2018-01-24 01:41:39
【问题描述】:

当我右键单击并尝试编译文件时,我在 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)

【问题讨论】:

  • 可能是程序路径问题中的“空格” - “C:\MinGW\MSYS”只是路径“C:\MinGW\MSYS 1.0”的一部分。您必须将路径放在引号中。
  • 如何编辑?当我转到路径变量部分时,编辑实用程序路径被禁用。
  • 我猜设置环境变量(系统变量)并不能解决这个问题。我不知道在 Netbeans 中在哪里编辑它。我现在明白这个问题了。
  • 或许可以
  • 好的,我必须在 C:\MinGW 中将 MSYS 1.0 重命名为 MSYS,然后相应地更改 make.exe 路径。有效。谢谢您的帮助。也许您可以详细回答问题,以便我可以接受并将其标记为帮助他人的解决方案。所以这是 Netbeans 中的一个错误?

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


【解决方案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

【讨论】:

  • 将默认安装目录命名为“Program Files”的全部意义在于强制正确处理所有 Windows 程序中的空格。跨平台的事情不打扰这个
猜你喜欢
  • 1970-01-01
  • 2018-04-02
  • 2015-03-21
  • 2014-12-28
  • 2012-04-05
  • 2016-12-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多