    <rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:admin="http://webns.net/mvcb/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:content="http://purl.org/rss/1.0/modules/content/">
     <channel>
        <title>ACCU  :: Quick Guide to MinGW (GCC for Windows)</title>
        <link>https://members.accu.org/index.php/articles/1222</link>
        <description>Professionalism in Programming</description>
        <dc:language>en-us</dc:language> 
        <dc:creator>Administrator</dc:creator> 
        <admin:generatorAgent rdf:resource="http://www.xaraya.org" /> 
        <admin:errorReportsTo rdf:resource="mailto:webeditor@accu.org" />
       <sy:updatePeriod>hourly</sy:updatePeriod>
       <sy:updateFrequency>1</sy:updateFrequency>
       <docs>http://backend.userland.com/rss</docs>




<div class="xar-mod-head"><span class="xar-mod-title">Programming Topics + CVu Journal Vol 15, #3 - Jun 2003</span></div>

<table border="0" cellpadding="1" cellspacing="0">
    <tbody>
    <tr>
        <td valign="top">
            Browse in :
       </td>
       <td valign="top">

                                            <a href="https://members.accu.org/index.php/articles/">All</a>

                     &gt;                         <a href="https://members.accu.org/index.php/articles/c13/">Topics</a>

                     &gt;                         <a href="https://members.accu.org/index.php/articles/c65/">Programming</a>
<br />

                                            <a href="https://members.accu.org/index.php/articles/">All</a>

                     &gt;                         <a href="https://members.accu.org/index.php/articles/c76/">Journals</a>

                     &gt;                         <a href="https://members.accu.org/index.php/articles/c77/">CVu</a>

                     &gt;                         <a href="https://members.accu.org/index.php/articles/c108/">153</a>
<br />

                                            <a href="https://members.accu.org/index.php/articles/c65-108/">Any of these categories</a>

                    -                        <a href="https://members.accu.org/index.php/articles/c65+108/">All of these categories</a>
<br />
</td>
   </tr>
   </tbody>
</table>




<div class="xar-error">
   <p>
 <strong>Note:</strong> when you create a new publication type,
the articles module will automatically use the templates
<em>user-display-[publicationtype].xt</em>
and <em>user-summary-[publicationtype].xt</em>.
If those templates do not exist when you try to preview or display a new article,
you'll get this warning :-)  Please place your own templates in themes/<em>yourtheme</em>/modules/articles . The templates will get the extension .xt there. </p>
</div>
<div class="xar-norm xar-standard-box-padding">
   <h1><strong>Title:</strong>&nbsp;Quick Guide to MinGW (GCC for Windows)</h1>
<p><strong>Author:</strong>&nbsp;</p>
<p>
<strong>Date:</strong> 03 August 2003 13:15:58 +01:00 or Sun, 03 August 2003 13:15:58 +01:00</p>
<p><strong>Summary:</strong>&nbsp;</p>
<p><strong>Body:</strong>&nbsp;<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e18" id="d0e18"></a>What is
MinGW?</h2>
</div>
<p>According to the MinGW website [<a href="#website">website</a>],
MinGW is a collection of freely available and freely distributable
Windows specific header files and import libraries combined with
GNU toolsets that allow one to produce native Windows programs that
do not rely on any 3rd-party DLLs. Unlike other ports of GCC to
Windows, the runtime libraries are not distributed using Gnu's
General Public License (GPL). The full license for MinGW can be
found on the License page [<a href="#license">license</a>] of the
website.</p>
<p>So, in simple terms MinGW is GCC [<a href="#gcc">gcc</a>] for
Windows complete with a Windows API.</p>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e34" id="d0e34"></a>Getting and
Installing MinGW</h2>
</div>
<p>Full information about the various components of MinGW and links
to the packages are available from the MinGW download page
[<a href="#download">download</a>]. There are a number of different
components, but only one is needed to install a basic MinGW and get
started. The current version of MinGW (at the time of writing) is
Version 2.0.0, although it is actually version 3.2 of GCC. The
Windows installation package is called <tt class=
"literal">MinGW-2.0.0-3.exe</tt>. Download this file, run it and
follow the instructions to install MinGW.</p>
<p>To use MinGW from the command line, the path to the MinGW BIN
folder must be added to Windows Path environment variable. To do
this on Windows 2000 go to the Control Panel and double click the
System Icon. Then click the Advanced tab and click the Environment
Variables button. Select 'path' in the User Variables for ...' list
box and click Edit. This brings up the 'Edit User Variable' dialog
box.</p>
<div class="figure"><a name="d0e47" id="d0e47"></a>
<p class="title c2">Figure 1. The Edit User Variable dialog box</p>
<div class="mediaobject"><img src=
"resources/edit%20user%20variable.jpg" alt=
"The Edit User Variable dialog box"></div>
</div>
<p>Move the cursor to the end of the 'Variable Value' edit box,
type a semicolon and add the path the the MinGW bin directory. The
default path is <tt class="literal">C:\MinGW\bin</tt>. Then click
Ok. To test MinGW open a command prompt, type the following and
press return:</p>
<div class="literallayout">
<p>g++ -version</p>
</div>
<p>This should give something similar to the following output:</p>
<div class="literallayout">
<p>g++ (GCC) 3.2 (mingw special 20020817-1)<br>
Copyright (C) 2002 Free Software Foundation,<br>
Inc.<br>
This is free software; see the source for<br>
copying conditions. There is NO<br>
warranty; not even for MERCHANTABILITY or<br>
FITNESS FOR A PARTICULAR PURPOSE.</p>
</div>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e64" id="d0e64"></a>Hello World
with MinGW</h2>
</div>
<p>The classic Hello World program is very easy with MinGW. Simply
create a file called something like <tt class=
"literal">HelloWorld.cpp</tt> and write the Standard C++ Hello
World program into it:</p>
<pre class="programlisting">
// HelloWorld.cpp
#include &lt;iostream&gt;
#include &lt;cstdlib&gt;
int main() {
  std::cout &lt;&lt; &quot;Hello, World!&quot;
            &lt;&lt; std::endl;
  return EXIT_SUCCESS;
}
</pre>
<p>To compile the Hello World program, type the following at the
command line from the directory which contains <tt class=
"literal">HelloWorld.cpp</tt>:</p>
<div class="literallayout">
<p>g++ -o HelloWorld HelloWorld.cpp</p>
</div>
<p>This should create an executable called HelloWorld.exe. Running
the executable should display the &quot;Hello, World!&quot; message.</p>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e83" id="d0e83"></a>Simple Make
Files with MinGW</h2>
</div>
<p>MinGW has a modified version of GNU Make [<a href=
"#make">make</a>] called <tt class="literal">mingw32-make.exe</tt>.
The MinGW port of Make operates more as Make was intended to
operate and gives less headaches during execution than the 'native'
MSVCRT dependent version. For more detailed information on using
Make see the GNU Make Manual [<a href=
"#make-manual">make-manual</a>].</p>
<p>To create a simple make file for the Hello World example, create
a file called <tt class="literal">makefile</tt>, and enter the
following rules:</p>
<pre class="programlisting">
# HelloWorld Makefile
HelloWorld : HelloWorld.o
g++ -o HelloWorld.exe HelloWorld.o
HelloWorld.o : HelloWorld.cpp
g++ -c HelloWorld.cpp
clean:
del *.exe *.o
</pre>
<p>To build <tt class="literal">HelloWorld.exe</tt> executable
enter the following at the command line and press return:</p>
<div class="literallayout">
<p>mingw32-make</p>
</div>
<p>To clean the project, or in other words remove the object files
and executables, type the following at the command line and press
return:</p>
<div class="literallayout">
<p>mingw32-make clean</p>
</div>
<p>Of course a make file for a single source file program such as
Hello World is overkill. The above example is intended to be a
starting point for larger projects.</p>
<p>The source code and make file [<a href="#source">source</a>]
used in this article is available to download from my website.</p>
</div>
<div class="bibliography">
<div class="titlepage">
<h2><a name="d0e122" id="d0e122"></a>References</h2>
</div>
<div class="bibliomixed"><a name="website" id="website"></a>
<p class="bibliomixed">[website] MinGW Website: <span class=
"bibliomisc"><a href="http://www.mingw.org" target=
"_top">http://www.mingw.org</a></span></p>
</div>
<div class="bibliomixed"><a name="license" id="license"></a>
<p class="bibliomixed">[license] MinGW License: <span class=
"bibliomisc"><a href="http://www.mingw.org/licensing.shtml" target=
"_top">http://www.mingw.org/licensing.shtml</a></span></p>
</div>
<div class="bibliomixed"><a name="gcc" id="gcc"></a>
<p class="bibliomixed">[gcc] GNU GCC: <span class=
"bibliomisc"><a href="http://gcc.gnu.org/" target=
"_top">http://gcc.gnu.org/</a></span></p>
</div>
<div class="bibliomixed"><a name="download" id="download"></a>
<p class="bibliomixed">[download] MinGW Download Page: <span class=
"bibliomisc"><a href="http://www.mingw.org/download.shtml" target=
"_top">http://www.mingw.org/download.shtml</a></span></p>
</div>
<div class="bibliomixed"><a name="make" id="make"></a>
<p class="bibliomixed">[make] GNU Make: <span class=
"bibliomisc"><a href="http://www.gnu.org/software/make/make.html"
target=
"_top">http://www.gnu.org/software/make/make.html</a></span></p>
</div>
<div class="bibliomixed"><a name="make-manual" id=
"make-manual"></a>
<p class="bibliomixed">[make-manual] GNU Make Manual: <span class=
"bibliomisc"><a href=
"http://www.gnu.org/manual/make/html_node/make_toc.html" target=
"_top">http://www.gnu.org/manual/make/html_node/make_toc.html</a></span></p>
</div>
<div class="bibliomixed"><a name="source" id="source"></a>
<p class="bibliomixed">[source] Source code and make file:
<span class="bibliomisc"><a href=
"http://www.paulgrenyer.co.uk/download/Quick_Guide_MinGW.zip"
target=
"_top">http://www.paulgrenyer.co.uk/download/Quick_Guide_MinGW.zip</a></span></p>
</div>
</div>
</p>
<p><strong>Notes:</strong>&nbsp;</p>
<p><em>More fields may be available via dynamicdata ..</em></p>
</div>
</channel>
</rss>
