What is the difference between g++ and gcc? Which one of them should be used for general c++ development?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
gccandg++are compiler-drivers of the GNU Compiler Collection (which was once upon a time just the GNU C Compiler).Even though they automatically determine which backends (
cc1cc1plus…) to call depending on the file-type, unless overridden with-x language, they have some differences.The probably most important difference in their defaults is which libraries they link against automatically.
According to GCC’s online documentation link options and how g++ is invoked,
g++is roughly equivalent togcc -xc++ -lstdc++ -shared-libgcc(the 1st is a compiler option, the 2nd two are linker options). This can be checked by running both with the-voption (it displays the backend toolchain commands being run).By default (and unlike
gcc), g++ also adds linker option-lm— to link againstlibmwhich contains implementations formath.h.