2013年11月26日 星期二

Step by step to compile a C++ program on Ubuntu.

Reference:
http://www.wikihow.com/Compile-a-C/C%2B%2B-Program-on-Ubuntu-Linux

1. Install compiling tool
sudo apt-get install build-essential

2.Create a directory to hold your programs
mkdir -p CCPP/HelloWorld

3. Go into the directory you created.
cd CCPP/HelloWorld

4. Create CPP file
gedit main.cpp

5. Fill code in main.cpp and save it.
#include<iostream>
using namespace std;
int main()
{
    cout << "\nHello World !\n" << endl;
    return(0);
}

6. Compile it.
g++ -Wall -W -Werror main.cpp -o HelloWorldCPP
7. Execute it.
./HelloWorldCPP



沒有留言:

張貼留言