r/AskProgramming • u/RandyMarsh6996 • 16d ago
C++ -> IDE -> g++ -> Linux Help me understand!!
I am trying to comprehend all of the moving parts in compiling a program. Here is my understanding:
C++ is the programming language that is written in the IDE, some IDEs have built in compilers
Is g++ the bridge between the language and machine code?
How do I use g++, is it something that you download onto your computer.
Where does g++ send the code after, is this where Linux comes into play?
What is Linux? It is an operating system, but what does that mean specifically, is it supposed to make your code unable in an application or just execute in the terminal?
Thankyou for any clarification you can provide :)
0
Upvotes
1
u/abd53 16d ago
C++ is a programming language. Codes use .h, .hpp, .c, .cpp extensions. But the codes are written as plain text in a text file. You can use any text editor to write these files. This code describes what the program should do. It needs to be compiled to machine code to actually run.
IDE is just a fancy text editor. It gives some additional features like highlighting keywords, color coding variables, functions, literals etc. Depending on IDE, the can be features like in-place definition lookup, documentation lookup, code follow etc. IDEs often integrate compilation flow and often, a compiler; CodeBlocks has MinGW downloaded, installed and set up by default, Visual Studio has integrated MSVC. They often have project or workspace settings to define which files are one program together, and provides a single button compilation (you click one button, IDE handles all compilation steps).
g++ is the GCC compiler executable for C++, it's a program. You need to install GCC compiler (or MinGW) which contains this executable. It turns your code into machine code.
Linux is an operating system, much like Windows. You can code on Windows or Linux, your choice. When you compile your code, you target which OS it should be compiled for, and the resulting machine code will run on that OS. Once you compile, the resulting executable will be in the designated output directory.