Program compiles and runs in Netbeans but not at terminal

I've got a simple program (at one point an empty program to test) that will run and compile fine in Netbeans, but at the terminal I get the error:
./main.0: 1: Syntax error: word unexpected (expecting ")")
Even when the program is empty, does nothing. What's going on here?
You're going to need to show us the code and the command you are using to compile the program.
I am not sure what command Netbeans uses to compile the source. I set it up to use g++, that is all I know. Where can I find what command it calls?

The source code is below, currently it is empty, and I get the same error with or without the body of code entered:

#include <cstdlib>
#include <stdlib.h>
#include <iostream>
#include <time.h>
#include <string>

using namespace std;

int main(int argc, char** argv) {

return 0;
}

When compiled and run in Netbeans 6.9 there is no error. However in Ubuntu, in the shell, calling the command ./main.o gets me the error:
./main.0: 1: Syntax error: word unexpected (expecting ")")
That's because you're only creating an obect file, you need to create an executable file. How are you compiling it? What command are you using?
I am using Netbeans, and I do not know what command it is calling. Or how to change it.
I can get the file to compile from the shell, using the command g++ main.cpp -0 main.out

It appears I don't know how to use Netbeans.
Am I right in saying,
1. if you compile from the shell and run from the shell it works
2. If you compile from Netbeans and run from Netbeans it works
3. If you compile from Netbeans and run from the shell, it does not work
?
Yes, that is correct. I'm guessing I'm not finding the executable created by Netbeans. Since main.o is an object file. Wish I had my work in front of me. I'll search some more tomorrow, thanks all for the replies.
Topic archived. No new replies allowed.