Gcc Development on Windows

Of course you can do all your development for CS444 by remote login to our Solaris UNIX servers, notably ulab.cs.umb.edu, which has the connected SAPCs needed for running your programs.  However, you might want to develop on Windows and transfer the files to ulab for running. This file discusses that possibility.

In the past, developers used Cgywin to set up a UNIX/Linux-like environment on Windows, in which gcc and its related tools could be run. More recently, a simpler option has become available with MinGW, a "Minimalist GNU for Windows" which supports GCC/tools. Once MinGW is installed, you can use command-line gcc in the ordinary Windows CMD window ("DOS box").  Also, the C/C++ Eclipse IDE supports MinGW as a "toolchain", so you can develop in C in the comfort of the eclipse GUI, as you may already be doing for Java.

For simple command line use, install MinGW, and add its bin directory to your Path. Then get a new CMD window to see that gcc is now available at the command line.  For ordinary programs, MinGW will build Windows executables that can be run from the command line. For cs444, however, we can compile code on Windows, but cannot run it there. To actually execute one of our programs, we need to transfer the sources to the ulab.cs.umb.edu system and rebuild them with the cross-compiler and cross-loader, and then use mtip to access the online SAPCs, as described elsewhere.

On Windows in a CMD window, with MinGW installed:

C:\cs\cs444> gcc test1.c      (simple hello program)

C:\cs\cs444> a.exe           (run it on Windows, since it is a portable program)

hello world!

C:\cs\cs444>

To run this program on SAPC, transfer test1.c to ulab.cs.umb.edu, copy the makefile from $pcex, and “make C=test1”, then use mtip to execute it.


For C/C++ eclipse, download the C/C++ Eclipse IDE.  If you already have the Java or JEE eclipse IDE, you may want to specify a different workspace location when you first run the IDE, although you can access Java projects from the C/C++ Eclipse IDE.

In the C/C++ eclipse GUI, read the Help> "C/C++ Development User Guide"> "Before You Begin"  before you try to set up a project. It's not as easy as the Java case. This writeup suggests that you download the MinGW distribution, as discussed above. Once that's working at the command line, it's time to try to set up a project in eclipse.

For cs444, we will be using makefiles to build programs. To set up a new C project, do New>C Project, give it a name and location (unchecking “Use Default Location”), and choose project type Makefile project>"Empty Project", and choose MinGW in the toolchain area.  See image below.Then click Finish. The makefile that will be running the project lives in the base directory of the project.  So the simplest arrangement is put all the .c files in the base directory as well. (Note that this is different from what we usually do for Java projects, where we have a "src" directory.) If you do use a src directory, just remember that the makefile that matters is in the base directory. To fit the default settings of eclipse projects, the makefile should have an “all” target for building, and a “clean” targer to clean the directory.

To build the project, right-click its icon in the Project Explorer, and chose Build Project, and similarly to clean the project.

 

What makefile to use?  Note that $pcex has makefile.offsite, the offsite-version makefile. To set up to compile the examples directory on Windows:

1.      Create directories include and examples within a pcdev directory on your Windows PC

2.      Transfer $pcinc to the local include directory:  when cd’d to that directory:

pscp user@linux1.cs.umb.edu:/groups/ulab/pcdev/include/* .

3.      Transfer $pcex to the local examples directory: when cd’d to that directory:

pscp user@linux1.cs.umb.edu:/groups/ulab/pcdev/examples/* .

4.      Make the offsite makefile the default makefile

copy makefile.offsite makefile

5.      mingw32-make clean   This should run the make tool from MinGW.

6.      mingw32-make C=timer   This should compile timer.c and create timer.opc. We can’t build timer.lnx on Windows

7.      mingw32-make test.exe    This should compile and load test.c creating test.exe, a Windows executable. Note that test.c is a portable program, i.e., it can run both on a real OS and also on SAPC.

8.      mingw32-make all  should compile all the examples.

9.      Once all this works, try setting up the eclipse project.

mingw_eclipse.jpg