Compile a C++ Code in Linux
The steps to compile a C++ program in Linux environment are essentially the same as the compiling in the C except for one diffrence. Instead of using "gcc" we use "g++" compiler to compile our code.Everything else remains the same.
- Open terminal and navigate to the directory where the source code file is stored.
- Compile using the following command:
- Here g++ is the compiler used to compile our file. All C++ files can end with any of the following extension:
- To execute the program use the following command:
- Since we have not used -o flag to name the output file, it is by default named as a.out
We can use all the flags in the same way we use in gcc.