c++ - Netbeans 和 C++ 安装

标签 c++ netbeans cygwin

我在使用 Netbeans 7.4 和 Cygwin 4.x 编译我的 C++ 程序时遇到了一个小问题。我已经完成了 netbeans 教程中的所有操作。我已经安装了 gcc、gdb、g++ 和 make 编译器。一切都在 Netbeans 属性中正确设置,每条路径。但是我仍然遇到同样的问题,我不知道这是什么问题。我正在尝试从 Netbeans 编译 Hello 示例。请帮我。这是错误日志:

"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory '/cygdrive/c/Users/Dragosh/Documents/NetBeansProjects/Welcome_2'
"/usr/bin/make"  -f nbproject/Makefile-Debug.mk dist/Debug/Cygwin_4.x-Windows/welcome_2.exe
make[2]: Entering directory '/cygdrive/c/Users/Dragosh/Documents/NetBeansProjects/Welcome_2'
mkdir -p build/Debug/Cygwin_4.x-Windows
g++    -c -g -o build/Debug/Cygwin_4.x-Windows/welcome.o welcome.cc
In file included from /usr/include/sys/reent.h:14:0,
             from /usr/include/wchar.h:6,
             from /usr/lib/gcc/x86_64-pc-cygwin/4.8.1/include/c++/cwchar:44,
             from /usr/lib/gcc/x86_64-pc-cygwin/4.8.1/include/c++/bits/postypes.h:40,
             from /usr/lib/gcc/x86_64-pc-cygwin/4.8.1/include/c++/iosfwd:40,
             from /usr/lib/gcc/x86_64-pc-cygwin/4.8.1/include/c++/ios:38,
             from /usr/lib/gcc/x86_64-pc-cygwin/4.8.1/include/c++/ostream:38,
             from /usr/lib/gcc/x86_64-pc-cygwin/4.8.1/include/c++/iostream:39,
             from welcome.cc:31:
/usr/include/sys/_types.h:72:20: fatal error: stddef.h: No such file or directory
#include <stddef.h>
                ^
compilation terminated.
nbproject/Makefile-Debug.mk:66: recipe for target 'build/Debug/Cygwin_4.x-Windows/welcome.o' failed
make[2]: *** [build/Debug/Cygwin_4.x-Windows/welcome.o] Error 1
make[2]: Leaving directory '/cygdrive/c/Users/Dragosh/Documents/NetBeansProjects/Welcome_2'
nbproject/Makefile-Debug.mk:59: recipe for target '.build-conf' failed
make[1]: *** [.build-conf] Error 2
make[1]: Leaving directory '/cygdrive/c/Users/Dragosh/Documents/NetBeansProjects/Welcome_2'
nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed
make: *** [.build-impl] Error 2


BUILD FAILED (exit value 2, total time: 467ms)

最佳答案

在上次更新到 2.830(参见 setup.exe 版本)后,cygwin 也遇到了这个问题。我使用的是 64 位版本。要验证我们是否有同样的问题,请尝试使用 g++ usgin cygwin 终端手动编译一些超简单的东西。

我检查过:

$ echo -e "#include <iostream>\n int main() { return 0; }" | g++ -xc++ -

得到:

In file included from /usr/include/sys/reent.h:14:0,
                 from /usr/include/wchar.h:6,
                 from /usr/lib/gcc/x86_64-pc-cygwin/4.8.1/include/c++/cwchar:44,
                 from /usr/lib/gcc/x86_64-pc-cygwin/4.8.1/include/c++/bits/postypes.h:40,
                 from /usr/lib/gcc/x86_64-pc-cygwin/4.8.1/include/c++/iosfwd:40,
                 from /usr/lib/gcc/x86_64-pc-cygwin/4.8.1/include/c++/ios:38,
                 from /usr/lib/gcc/x86_64-pc-cygwin/4.8.1/include/c++/ostream:38,
                 from /usr/lib/gcc/x86_64-pc-cygwin/4.8.1/include/c++/iostream:39,
                 from <stdin>:1:
/usr/include/sys/_types.h:72:20: fatal error: stddef.h: No such file or directory
 #include <stddef.h>
                    ^
compilation terminated.

我注意到这里有两个gcc的文件夹 C:\cygwin\lib\gcc\x86_64-pc-cygwin\4.8.1 C:\cygwin\lib\gcc\x86_64-pc-cygwin\4.8.2

和 g++ --version 给出 4.8.2

运行 Cygwin 的最新 Setup.exe 并查找已安装的数据包显示 gcc-core 和 gcc-g++ 的版本不匹配:

gcc-core = 4.8.2-1
gcc-c++ = 4.8.1-3

我将 gcc-core 降级到 4.8.1-3 并解决了这个问题。

关于c++ - Netbeans 和 C++ 安装,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19642787/

相关文章:

c++ - 无法在两个函数之间复制值

java - 如何解决 Netbeans 12.0 IllegalAccessError?

java - 从 Netbeans 转移到 Eclipse,现在 "Severe: PWC6117: File "null“未找到”

cygwin - 尝试运行 Docker 导致退出代码 127

c++ - 对默认参数使用右值引用

c++ - 将 _bstr_t 复制到 wchar_t* 的正确方法

c++ - boost 线程和类

java - 显示MySQL数据库中的表名及其记录数

c++ - 在 Microsoft Windows 上安装 RQuantLib

c++ - *** 内部错误 : unable to open jobserver semaphore '3,4' : (Error 2: The system cannot find the file specified. )。停止