Home > Backend Development > C++ > body text

GCC vs. G : Why Use G for C Compilation?

DDD
Release: 2024-11-26 11:24:13
Original
649 people have browsed it

GCC vs. G  : Why Use G   for C   Compilation?

Compiling C with GCC and the Difference Between GCC and G

While GCC is known for compiling C programs, it can also compile C code. The errors encountered when attempting to compile info.c using "gcc info.C" are not compiler errors but linker errors.

To resolve the linking issue, it is necessary to add the "-lstdc " flag to the compilation command:

gcc info.C -lstdc++
Copy after login

This tells the linker to link the program against the standard C library.

However, for simplicity, it is recommended to use g for compiling C programs.

Difference Between GCC and G

As explained by Rup in a comment on another answer:

  • Both gcc and g choose the appropriate back-end compiler based on the file extension (.c or .cc).
  • gcc links against the standard C and GCC helper libraries by default, regardless of input language.
  • g includes libstdc in its link step, regardless of input language.
  • g compiles all C source (.c) as C .

The above is the detailed content of GCC vs. G : Why Use G for C Compilation?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template