
1) if you have single file Only “main.cpp”
1. 1 compile and run c++ without giving target name
How to compile:
g++ main.cppone a.out file will be generated by default
How to Run
./a.out1. 2 compile and run c++ with target name
How to compile:
g++ main.cpp -o testone test.out file will be generated by default
How to Run
./test2) Multiple .cpp files:
suppose we three files
main.cpp
chess.cpp
chess.h
How to compile multiple files in c++
g++ main.cpp chess.cpp -o output Here we have three file but we need to compile only chess.cpp file not header file
How to run
./output3) All .cpp files
g++ *.cpp -o outputname./outputname4) Advanced setting to run c++
If you want to include standard while compiling then you can do with following ways
Compiling c++ with -std=c++11
g++ -std=c++11 main.cpp chess.cpp -o output How to run
./output 5) Compile CPP make file
Make filename # creates “main” application ./main #Run application on terminal6) C++ Compilation with activates all Warnings
”-Wall” activates all Warnings
g++ -Wall main.cpp -o outputRun
./output