What is the difference between g++ and gcc?

转载自:http://stackoverflow.com/questions/172587/what-is-the-difference-between-g-and-gcc/172592#172592

------------------------------------------------------------  我是分割线  ---------------------------------------------------------------------------

gcc and g++ 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 (cc1 cc1plus ...) 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 [1] and [2]g++ is equivalent to gcc -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 -v option (it displays the backend toolchain commands being run).



[1]:https://gcc.gnu.org/onlinedocs/gcc/Link-Options.html
[2]:https://gcc.gnu.org/onlinedocs/gcc/Invoking-G_002b_002b.html
请使用浏览器的分享功能分享到微信等