Programming and Scripting :: Compiler



Cypher, try this example program called hello.cpp

Code Sample
#include <iostream>

using namespace std;

int main()
{
  cout << "Hello World" << endl;
  return 0;
}


Enter this into a text editor (if you don't know open beaver from the icon and use that) and save it as hello.cpp in your home directory (/home/dsl).

To compile it, open an xterminal (which should put you in the /home/dsl directory) and enter the command line:

g++ -o hello hello.cpp

This should produce and executable called hello, so type hello in the shell and hit return and it should print the hello message.  gcc is the C compiler, g++ is the c++ compiler.  You might want to run the g++ program from the same directory that your *.cpp files are in until you get used to paths and such.


original here.