2. Solaris Compilers: Cosmos

At the time of writing (2001, June) there are three versions of the Sun Workshop Compilers available on Cosmos: 4.2, 5.0 and 6.0. (We have had problems with the Fortran 5.0 compilers; we currently know of no problems with the C 5.0 compilers.) The Workshop 6.0 compilers are newly installed and have not yet been fully tested.

2.1. Using the Workshop 6.0 Compilers and IDE (Forte Developer)

Forte Developer is Sun's new name for what would be Workshop 6. Forte includes C and C++ compilers, Fortran 77, 90 and 95 compilers, and the dbx debugger, as for previous versions of Workshop --- Forte also includes an Integrated Development Environment (IDE) and a GUI-development tool.

The simplest way to use Forte (for most people) is to execute the command
    setup_forte6
immediately after logging on --- this sets your path appropriately, then the commands f77, f90, f95, cc and CC access the Fortran 77, 90 and 95 compilers, and the C and C++ compilers, respectively; the command dbx accesses the debugger, workshop starts the IDE, and visu starts the GUI-development tool.

Should you have trouble with the setup_forte6 command, or not wish to use it, then pre-pending
    /software/workshop6/utils/SUNWspro/bin
to your environment path, and
    /software/workshop6/utils/SUNWspro/lib
to your environment library-path with, for example, the commands
    export PATH=/software/workshop6/utils/SUNWspro/bin:$PATH
    export LD_LIBRARY_PATH=/software/ ... /SUNWspro/lib:$LD_LIBRARY_PATH
will make the above commands/applications directly accessible (i.e., without needing to resort to using the full path) and ensure the necessary libraries are available to you.

Since Forte has not yet been fully tested, we would welcome any feedback regarding successes as well as any problems.

2.2. Using the Workshop 5.0 Compilers

The Workshop 5.0 compilers are picked up by default. To use the C compiler simply type
     cc <source_file> 
at the command line (cc in lower case); for the C++ compiler simply type (CC in upper case)
     CC <source_file>
The full paths are /software/SUNWspro/bin/cc and /software/SUNWspro/bin/CC, though these should not usually be needed as /software/SUNWspro/bin will be on your path by default.

2.3. Example --- A Simple Programme

Suppose we want to compile, link and run the following simple programme
    #include <stdio.h>
  
    main() {
        printf("Hello world!  \n)";
      }
which resides in hello.c. Type
     cc hello.c 
If the source code has been typed in correctly you will get no messages from the compiler; alternatively type
    cc -v hello.c
for more information:
    cc -v hello.c 
    "hello.c", line   6: warning: Function has no return statement : main
An excutable binary called a.out will be produced (it is assigned the executable file attribute automatically). To run this simply type the file name:
    a.out
    Hello world!  
The programme prints the string "Hello world!" to the screen. You may want to change the name of the executable produced by the compiler --- use the -o option:
    cc -o hellow hello.c
will produce an executable called hellow. N.B. Using the -o option is a good idea --- if a file called a.out already exists the compiler will overwrite it without warning.

2.4. Full Documentation

The full documentation (Users Guides) for the C and C++ Compilers is available on-line at docs.sun.com:

2.5. Using the Workshop 4.2 Compilers

The full paths for the Workshop 4.2 compilers are /software/SUNWspro_4.2/bin/cc and /software/SUNWspro_4.2/bin/CC so that, for example, one can type
     /software/SUNWspro_4.2/bin/CC <source_file> 
to use the 4.2 C++ compiler.

2.6. Mixing (the 4.2, 5.0 and 6.0) Compilers

As a rule, don't! All source code to be linked should be compiled with the same compiler. Not following this rule can lead to linking and (unpredictable) run-time problems.


...previousup (conts)next...



About this document:

Produced from the SGML: /home/isd/public_html/_compilers_unix_c/_reml_grp/compilers_C.reml
On: 20/2/2002 at 10:4:39
Options: reml2 -i noindex -l long -o html -p multiple