Gcc Development on Linux or MacIntosh OS/X

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 Linux or Mac and transfer the files to ulab for running. This file discusses that possibility.

Mac comes with gcc and its tools. Linux provides packages for add-ons like this, but different distributions of Linux have different package-handling software. For Ubuntu, see CompilingSoftware. For other distributions, do a Google search.  You need make as well as gcc, but I think they usually come together.

In a shell window, test your setup:

$ gcc test1.c      (simple hello program)

$ a.out

hello world!


To run this program on SAPC, transfer it 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.

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, and choose project type Makefile>"Empty Project.  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.

 

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

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

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

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

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

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

5.      Make the offsite makefile the default makefile:

cp makefile.win makefile

6.      make clean   This should run the make tool.

7.      make C=timer   This should compile timer.c and create timer.opc. We can’t build timer.lnx off-site

8.      make test.exe    This should compile and load test.c creating test.exe, a Linux/Mac executable. Note that test.c is a portable program, i.e., it can run both on a real OS and also on SAPC.