- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to compile and run the C++ program?
Once you've got your compiler and source program ready, it is very easy to compile and run a C++ program. Assuming that you've installed GCC compiler, and you have a source.cpp file that you want to compile, follow the following instructions to compile and run it.
Step 1 − Open a new terminal window or cmd if you are on windows.
Step 2 − Change the directory to the directory in which you have your source.cpp file. For example, if it is in C:/Users/Dell/Documents, enter your command line −
$ cd 'C:/Users/Dell/Documents'
Step 3 − Now enter the following command to compile the source file using g++.
$ g++ -o <name-you-want-to-give> source.cpp
In place of <name-you-want-to-give> replace it by any name like myprogram, etc.
Step 4 − Run it! Now you can run the program using −
- How to compile & run a Java program using Command Prompt?
- Explain Compile time and Run time initialization in C programming?
- How to Edit, Compile, and Execute a C++ Program?
- How to compile a java program
- What is the difference between compile time errors and run time errors in Java?
- Are Generics applied at compile time or run time?
- How to run Perl Program?
- How to run Python Program?
- Compile the sequential model with compile method - Keras and Python
- How to run a java program
- How to run Java package program
- How to Run a Python Program
- How to run JavaTuples program in Eclipse?
- How to compile and execute C# programs on Linux?
- How to compile and execute C# programs on Windows?