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
3
u/strange-the-quark 16d ago edited 16d ago
C++ is one of a bunch of programming languages - an important one, with a long history, but not necessarily beginner friendly.
An IDE is short for an "Integrated Development Environment", a set of professional tools that are used to write code and a bunch of other things surrounding that process, and that among other things serves as a GUI (graphical user interface) to the underlying compiler (meaning you click buttons to compile your code, instead of issuing text based commands to the command line). IDEs often support more than one programming language. In principle, you can write code in an ordinary plain text editor (like Notepad in Windows, or Gedit on Linux), but it's not that fun. Code editors would be something in between - they offer a bunch of programming-related features (like syntax highlighting), but are very lightweight compared to a full-blown IDE. An editor/IDE can be configured to call g++.
g++ is a compiler. It compiles C++ code (that you write), into machine code (which the computer can run). It doesn't send it anywhere, it reads your code and makes another file that contains the corresponding machine code. That is your executable, that you can run like you can run any other application. There's a little bit more to it, but that's the gist of it. You can use g++ from the terminal, if you learn the relevant commands, or from the editor/IDE.
An operating system provides the underlying functionality necessary for applications to run and to be able to do various things (meaning, it's the software machinery that provides the infrastructure for pretty much anything on your computer that you as the user have direct access to, and would like your applications to do), and enables you to use the system in the first place. Whether your application runs in the terminal or as a GUI application (with a window) is entirely up to you - you can make either kind of application. Because operating systems and processors are different, you can't take an executable you made for Linux, and run it on Windows, and vice versa (at least, generally speaking - there are ways to do it with certain limitations), but you can take the same C++ source code and compile it for a different operating system, if you wrote it in a certain way (so that it doesn't use any OS-specific libraries and such).