Here is the collection of my notes on general C++ projects development. Hope it will help with your understanding on this programming language.
Generally speaking, they are all compilers from GNU, but it is worth noting that:
.cfile as a C program while
g++will recognize it as a C++ program. For
.cppfile, both of them will consider it as a C++ program.
- During the compiling process,
gccautomatically. So they are equivalent for C++ program. However, we can’t use gcc commands to link C++ libraries, so we use g++ for linking libraries in general.
- You could use both
g++/gccfor compiling and
g++/gcc -lstdc++for linking. For example:
gcc main.cpp -lstdc++
one command version:
This simple command actually performs:
Here the default output file is
In this stage, the compiler will add the header files into the source code.
gcc -E hello.c -o hello.i
- Effect: preprocess
hello.cand the output is
The second stage is compiling where the
gcc will check the syntax of the source code and translate it into assembly language.
gcc -S hello.i -o hello.s
- Effect: Compile the
In the assembling stage, the purpose is to convert the
.s file into binary file