Read Also
In learning a programming language requires several things to be prepared. What is prepared of course depends on what language we want to learn.
On this occasion we will learn how to install C and C++ language compilers using mingw. Why do we need to install this compiler? To answer this we need to know what a compiler is.
What is a Compiler?
A compiler is a computer program that translates commands that we write in a programming language into a language that is understood by the computer.
Without this compiler, of course, we will have difficulty communicating with the computer.
The concept is the same as google translate, which converts commands in a programming language into machine language. That way the machine can understand what we ordered.
C/C++ Language Compiler
Now, for C and C++ languages, we need a compiler so that the commands we write can be run on our computers. In C and C++ the compiler used is MingGW. You can download it here.
After you download the installer of the MinGW compiler, here is how to install the C/C++ language compiler on a windows computer.
1. Open the downloaded folder or file earlier. Double click the downloaded installer, a new window will appear as shown in the image.
2. Extract and install MinGW to drive C:\ so in C:\MinGW
3. Open Run (Windows+R) then type "sysdm.cpl" without the quotes then select the Advanced tab --> Environment Variables
4. Click the path in system variables -> Edit -> New -> type C:\MinGW\bin -> Ok -> Ok -> Ok.
If you click edit in system variables, it looks different like the picture above, just add ";C:\MinGW\bin" at the end, remember only add don't delete what is already listed there.
5. Open CMD and change the directory where the .cpp file is stored.
#How to change directory in cmd
- For example the file is in D:\LabTI\PAA
- Type d: ENTER
- type cd LabTI ENTER
- type cd PAA ENTER
6. Compile the g++ syntax file filename.cpp -o objectname
For example; g++ Exercise1.cpp -o Exercise1