简体   繁体   中英

Netbeans C/C not compiling

I installed the NetBeans IDE 7.3.1 almost a week ago and still haven't been able to get it to compile anything.
I'm using the Cygwin 's compiler for C/C++, and I get the following error message for a simple "Hello World" program:

"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory `/cygdrive/c/Users/CaptFuzzyboots/Documents/NetBeansProjects/Hello World'
"/usr/bin/make"  -f nbproject/Makefile-Debug.mk dist/Debug/Cygwin_1-Windows/hello_world.exe
make[2]: Entering directory `/cygdrive/c/Users/CaptFuzzyboots/Documents/NetBeansProjects/Hello World'
mkdir -p build/Debug/Cygwin_1-Windows
rm -f build/Debug/Cygwin_1-Windows/main.o.d
gcc    -c -g -MMD -MP -MF build/Debug/Cygwin_1-Windows/main.o.d -o build/Debug/Cygwin_1-Windows/main.o main.c
make[2]: gcc: Command not found
nbproject/Makefile-Debug.mk:66: recipe for target `build/Debug/Cygwin_1-Windows/main.o' failed
make[2]: *** [build/Debug/Cygwin_1-Windows/main.o] Error 127
make[2]: Leaving directory `/cygdrive/c/Users/CaptFuzzyboots/Documents/NetBeansProjects/Hello World'
nbproject/Makefile-Debug.mk:59: recipe for target `.build-conf' failed
make[1]: *** [.build-conf] Error 2
make[1]: Leaving directory `/cygdrive/c/Users/CaptFuzzyboots/Documents/NetBeansProjects/Hello World'
nbproject/Makefile-impl.mk:39: recipe for target `.build-impl' failed
make: *** [.build-impl] Error 2


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

EDIT

I fixed this by just making a new toolkit and adding the base directory as Cygwin -> bin.

The problem now is that I keep getting

Unable to start pty process

gcc: Command not found

  1. You should check whether you have installed gcc (plus gdb and make )

    1. via MinGW :

      MinGW+NetBeans (just look at the screenshots, you don't have to understand Hungarian)

      MinGW编译器套件

      MinGW安装经理

    2. via Cygwin :

      http://www.eecg.utoronto.ca/~aamodt/ece242/cygwin.html

      Cygwin,gcc,gdb,make

  2. You should also check whether paths are correct in NetBeans:

    Tools > Options > C/C++ > Build Tools :

    (At the time of creating the screenshot, I had MinGW installed in C:\\Programs\\MinGW , BUT if you have it installed in C:\\MinGW (which is the default), this correct, too! The only important thing is that you should install MinGW in a path which doesn't contain whitespaces.)

    NetBeans:工具>选项> C / C ++>构建工具

    This is what it looks like when paths are incorrect, letters are red:

    NetBeans:工具>选项> C / C ++>构建工具,错误的路径

    Note: I have MinGW installed, but it doesn't change the fact that you should check whether YOUR paths are correct.

  3. You should also take care the right Configuration is selected in project Properties (right click on project) > Build - The right "Tool collection" has to be selected (on which the paths above are correct):

    NetBeans:项目属性>构建>工具集合

Unable to start pty process

Related answer: Can build, but can't run C code in netbeans (but it works in command line)

So right click on the project, Properties > Run > Console Type > External Terminal (instead of eg "Internal Terminal"). Here is a screenshot:

NetBeans:项目,属性>运行>控制台类型>外部终端

Here is your problem:

gcc: Command not found 

Cygwin is not a compiler, it's a unix-like environment for Windows. Gcc is the compiler. You have to install gcc with Cygwin before it will work.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM