How to Compile and Run a C++ Program Using g++ on Ubuntu 18.04 LTS?

  • 5 years ago
How to Compile and Run a C++ Program Using g++ on Ubuntu 18.04 LTS?

Step 1: To check whether you have g++ installed or not on your ubuntu, Open 'Terminal.'

Step 2: Type the command below, and then hit enter.

g++ --version

If you get version info of g++ that means you g++ installed. if you get error like that 'command not found' or 'command not recognized' that means you don't have g++ installed.

Type the command below to install g++, and then hit Enter:-

sudo apt install build-essential

follow the instructions on terminal, and install it.

Step 3: Now, go to the Directory where you have your C++ program file. After that type the command below to compile it, and hit enter.

g++ your_c++_Program_filename -o filename_that_you_want_to_give

Step 4: To run it, type the command below, and then hit enter.

./filename_that_you_have_given


It's done.




Thanks for watching, please like and subscribe

==============================================
https://www.facebook.com/HowtoTutorialsByAmit/

Recommended