How to make Hello World in Netbeans?

I am trying to write a simple Hello World in Netbeans. My host OS is Open Suse. I downloaded Netbeans with c++. I went into plugins and enabled c++. I start a c/c++ app and select c++ in the drop down menu in the wizard. I then go into main and enter cout << "hello world."


When typing the code in the IDE, it puts the red squiggleys under cout which tells me something is way wrong if it doesn't know cout. What am I doing wrong?


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
  
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/* 
 * File:   main.cpp
 * Author: david
 *
 * Created on May 2, 2018, 12:31 PM
 */

#include <cstdlib>

using namespace std;

/*
 * 
 */
int main(int argc, char** argv) {
    cout << "Hello World\n";

    return 0;
}
closed account (E0p9LyTq)
std::cout is not part of the C stdlib (<cstdlib>) library, you have to include <iostream>.

1
2
3
4
5
6
#include <iostream>

int main()
{
   std::cout << "Hello World\n";
}
I tried both iostream and iostream.h and same thing...

1
2
3
4
5
6
#include <iostream.h>

int main()
{
   std::cout << "Hello World\n";
}


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
cd '/home/david/NetBeansProjects/CppApplication_1'
/usr/bin/gmake -f Makefile CONF=Debug
"/usr/bin/gmake" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
gmake[1]: Entering directory '/home/david/NetBeansProjects/CppApplication_1'
"/usr/bin/gmake"  -f nbproject/Makefile-Debug.mk dist/Debug/GNU-Linux/cppapplication_1
gmake[2]: Entering directory '/home/david/NetBeansProjects/CppApplication_1'
mkdir -p build/Debug/GNU-Linux
rm -f "build/Debug/GNU-Linux/main.o.d"
gcc    -c -g -std=c99 -pedantic -Wall -Wextra -Werror -MMD -MP -MF "build/Debug/GNU-Linux/main.o.d" -o build/Debug/GNU-Linux/main.o main.cpp
gcc: error trying to exec 'cc1plus': execvp: No such file or directory
gmake[2]: *** [nbproject/Makefile-Debug.mk:68: build/Debug/GNU-Linux/main.o] Error 1
gmake[2]: Leaving directory '/home/david/NetBeansProjects/CppApplication_1'
gmake[1]: *** [nbproject/Makefile-Debug.mk:59: .build-conf] Error 2
gmake[1]: Leaving directory '/home/david/NetBeansProjects/CppApplication_1'
gmake: *** [nbproject/Makefile-impl.mk:40: .build-impl] Error 2

BUILD FAILED (exit value 2, total time: 215ms)
closed account (E0p9LyTq)
Your gcc configuration (line 9) "smells" a bit odd, -std=c99 is using the C99 standard to compile. It should be -std=c++11.

I don't use Netbeans for compiling C/C++ code. Other than a possible setup configuration problem I don't have a clue.
It seems more like a C project.
Try this:
1
2
3
4
5
6
7
8
9
10
#include <stdlib.h>
#include <stdio.h>

int main() 
{
  printf("Hello world");
  getchar();

 return 0;
}
Topic archived. No new replies allowed.