(I am using the latest version of Ubuntu 10.10, your commands may vary depending on your distribution)
First we need to open the command prompt by clicking Applications > Accessories > Terminal
With the terminal open type the following command:
Code: Select all
sudo apt-get install build-essential
The install process will then start:
Once the install has finished, it is time to create your first program.
(In this case I created a C++ program. You can also create C programs, however not with this method. I apologise, I will not be showing you how to create a C program as I am not familiar with the C language)
Lets do so by typing:
Code: Select all
sudo gedit <name of your program goes here> .cpp
A text editor will then open up like so and you can then type in you program. Save your program when done:
You can copy this code if you like:
Code: Select all
#include <iostream>
using namespace std;
int main()
{
cout << "Hello world!" << endl;
return 0;
}
Code: Select all
g++ <name of your program>.cpp -o test
If you copied the code correctly then you will see the next prompt username@computer:~$
However, if there are any errors they will be shown on the next prompt. For example:
Once all errors have been corrected you can now run your program by typing:
Code: Select all
./test
I hope that helps, now go get your programming on.