[CCP14 Home: (Frames | No Frames)]
CCP14 Mirrors: [UK] | [CA] | [US] | [AU]

(This Webpage Page in No Frames Mode)


Tutorials and Examples

Installing and Setting up Free Compilers and Software Creation Toolkits

Installing and Setting up the Cygwin/Cygnus GNU Win32 C/C++/GCC/G++/G77 C and Fortran for Windows Compiler

The CCP14 Homepage is at http://www.ccp14.ac.uk

[Tutorials page] [Compilers page]

In this new version (13th July 2000) Cygnus GNU-Win32 C/C++ compiler no longer installs via a commercial Windows Wizard but a new Windows programs which installs off the internet. (a recent version of the installer did this via a DOS style program). Please keep in mind that the installer seems to still be in development so some of these screen dumps may not match exactly.

The other major changes over the old installation:

  • The directories roughly match a UNIX System (c:\bin, c:\lib, etc or the new default of c:\cygwin\bin, c:\cygwin\lib, etc)

  • The installer is now much reduced in size and can install the rest of the distribution off the internet or local disk.

  • A fortran F77/G77 compiler is now included by default.

  • More UNIX style tools and programs are now included.

Also refer to: Scientific Fortran Links and Creating GNU G77 Fortran Compiler compatible Dynamic Arrays (Automatic Arrays/Dynamic Memory Allocation)

The installer for the Cygnus compiler for Windows can be downloaded from a variety of sources as defined below. Just go into the "latest" directory and get the setup.exe file and put it into a temporary directory. (e.g., c:\temp)

If you have problems obtaining the programs via FTP, it could be that this is a problem with your firewall. A quick fix is to use the following HTTP address.

Installing the Compiler

In the Windows explorer run the setup.exe file you just downloaded to be given the following screen.

Cygwin Installation Screen

If you are on a modem or wish to install on several machines, you may like to Download from Internet to Current Directory so that you have a complete copy of the install files that you can then use at a later time on a variety of machines. However, the following Internet install does load all the install files down as part of the install (and does not delete them)

For this example, we will go for Install from Internet as the example machine has a permanent high speed internet connection.

Selecting internet based install

The Cygwin installer will then prompt the directory you wish to install into. By default, confirm the selection of c:\cygwin.

Cygwin providing a list of available mirrors to install from

The following options can seem minorly confusing but go for Use IE5 Settings. If you have a firewall or are forced to go via a proxy server, you may have to configure your proxy settings (which don't seem fully functional on the July 13th 2000 version of the installer).

Sellecting IE5 settings

Cygwin will then download a list of Mirror sites.

Sellecting IE5 settings

Select the mirror that looks closest or select "other" to insert a custom web or ftp address. In this case, we will select the CCP14 mirror by typing the corresponding number; after which Cygwin will start downloading and extracting the distribution files. This may take a while depending on the speed of your CPU and internet connection.

Also, as mentioned, if you have trouble with an FTP download (firewalls can have this effect, try switching to an HTTP based site)

(If performing an update, the Cygwin installer will refresh the required distribution files and if nothing needs to be updated, will report this)

Cygwin prompting for local or internet based install

Cygwin downloading the install files

Cygwin installing the binary files

Cygwin install completed

On completion, the Cygwin installer will exit, having created the following directory system.

  • c:\cygwin\bin
  • c:\cygwin\etc
  • c:\cygwin\lib
  • c:\cygwin\tmp
  • c:\cygwin\usr
  • c:\cygwin\var

You may like to delete the distribution files now remaining in your temporary directory (in this case C:\temp)

Now edit your c:\autoexec.bat file and add the following line so that the c:\cygwin directory is put in the default path (using sysedit is a user friendly way of doing this):

SET PATH=%path%;c:\cygwin

Now reboot the computer for the change to the autoexec.bat file to take effect.

Just type cygwin to enter the Cygwin bash shell to start being happy. For a first time, this will create a user area in the c:\cygwin\home\ directory. This behaviour can be over-ridden in the Cygwin install.

Running the Cygwin bash shell

Using the C compiler

After runing cygwin to bring up the Cygwin Bash interface.

You can now start compiling up programs including the following "Hello World" program to test things out.

#include <stdio.h>

  int main(void)
    printf("Hello, world!\n");
    return 0;

Cygwin comes with a vi/vim editor those who like this type of thing. Though the freeware PFE editor for Windows is very good.

Editing a file in vi

Build the executable using the command gcc hello.c -o hello.exe

Running a C program compiled in cygwin

To run of these programs, you may have to include the CYGWIN1.DLL file in the present working directory. (located in the c:\cygwin\bin directory)

Using the GNU Fortran G77 compiler

Type cygwin to bring up the Cygwin Bash interface.

For Fortran, you can build a "Hello World" program and compile it to test things out.

      DO 10 I=1, 10
          PRINT *, 'Hello World #', I

Build the executable using the command g77 -o hello.exe hello.for

To run of these programs, you may have to include the CYGWIN1.DLL file in the present working directory. (located in the c:\cygwin\bin directory)

Running a fortran program compiled in cygwin with the CYGWIN1.DLL file in the same working directory

[Tutorials page] [Compilers page]

[CCP14 Home: (Frames | No Frames)]
CCP14 Mirrors: [UK] | [CA] | [US] | [AU]

(This Webpage Page in No Frames Mode)

If you have any queries or comments, please feel free to contact the CCP14