GNU Compiler Collection: Difference between revisions

From Rosetta Code
Content added Content deleted
No edit summary
 
 
(8 intermediate revisions by 4 users not shown)
Line 1: Line 1:
The GNU Compiler Collection, or GCC, is a multilanguage compiler supporting multiple target architectures. As of version 4.1, the main branch includes support for Ada, C, C++, Fortran, Java, Objective-C, and Objective-C++. Support for other languages is possible through the creation of a compiler front-end.
{{Compiler}}[[Category:Encyclopedia]]The '''GNU Compiler Collection''', or '''GCC''', is a multi-language compiler supporting multiple target architectures. As of version 4.1, the main branch includes support for [[Ada]], [[C]], [[C++]], [[Fortran]], [[Java]], [[Objective-C]], and [[Objective-C++]]. Support for other languages is possible through the creation of a compiler front-end.


==Basic Usage==
==Basic Usage==
Line 5: Line 5:
Any of GCC's supported languages may be compiled through the simple command-line construct:
Any of GCC's supported languages may be compiled through the simple command-line construct:
<pre>gcc (source-file)</pre>
<pre>gcc (source-file)</pre>
However, some languages depend on the [[linking]] of libraries, such as C++'s [[Standard Template Library]], to reach their full potential. In GCC, one way to include the STL is to change the way the compiler is called:
However, some languages depend on the [[link time|linking]] of libraries, such as C++'s [[Standard Template Library]], to reach their full potential. In GCC, one way to include the STL is to change the way the compiler is called:
<pre>g++ (source-file)</pre>
<pre>g++ (source-file)</pre>
In the above two examples, GCC will produce a binary file named '''a.out''', barring any [[compile-time errors]]. This is the executable form of the code compiled. If it is preferable to have a binary of a different name, and it usually is, one can use the '''-o''' command-line option:
In the above two examples, GCC will produce a binary file named <tt>a.out</tt>, barring any [[compile time|compile-time]] errors. This is the executable form of the code compiled. If it is preferable to have a binary of a different name, and it usually is, one can use the <tt>-o</tt> command-line option:
<pre>gcc (source-file) -o mybinary</pre>
<pre>gcc (source-file) -o mybinary</pre>
''or''
''or''
<pre>g++ (source-file) -o mybinary</pre>
<pre>g++ (source-file) -o mybinary</pre>
These example behaves the same as their sibling examples, with the exception that they create a binary named '''mybinary''' instead of '''a.out'''.
These example behaves the same as their sibling examples, with the exception that they create a binary named <tt>mybinary</tt> instead of <tt>a.out</tt>.


==See Also==
==See Also==
* [http://en.wikipedia.org/wiki/GNU_Compiler_Collection Wikipedia: GNU Compiler Collection]
* [http://gcc.gnu.org/ GCC official home page]
* [[wp:GNU Compiler Collection|GNU Compiler Collection on Wikipedia]]
* [http://gcc.gnu.org/onlinedocs/ GCC Documentation]
* [http://gcc.gnu.org/onlinedocs/ GCC online documentation]
* [http://gcc.gnu.org/install/binaries.html An incomplete list of third-party binary distributions] for systems that don't already have a compiler installed.
* [http://mingw.org/ MinGW], a widely-used port of GCC to [[Windows]]
* [https://mingw-w64.org MinGW-w64], a popular fork of MinGW that adds Win64 support and additional tools and APIs
* [http://tdm-gcc.tdragon.net/ TDM-GCC], another Windows port (not listed in the third-party distribution page above)
* [http://www.delorie.com/djgpp/ DJGPP], a widely-used port of GCC to [[DOS]]

Latest revision as of 06:00, 24 August 2017

GNU Compiler Collection is an example of a compiler. You may find the programming tasks that have been solved using it here.

The GNU Compiler Collection, or GCC, is a multi-language compiler supporting multiple target architectures. As of version 4.1, the main branch includes support for Ada, C, C++, Fortran, Java, Objective-C, and Objective-C++. Support for other languages is possible through the creation of a compiler front-end.

Basic Usage

Any of GCC's supported languages may be compiled through the simple command-line construct:

gcc (source-file)

However, some languages depend on the linking of libraries, such as C++'s Standard Template Library, to reach their full potential. In GCC, one way to include the STL is to change the way the compiler is called:

g++ (source-file)

In the above two examples, GCC will produce a binary file named a.out, barring any compile-time errors. This is the executable form of the code compiled. If it is preferable to have a binary of a different name, and it usually is, one can use the -o command-line option:

gcc (source-file) -o mybinary

or

g++ (source-file) -o mybinary

These example behaves the same as their sibling examples, with the exception that they create a binary named mybinary instead of a.out.

See Also