home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


/usr/ccs/bin/cc [options ] files

Compile one or more C source files (file .c ), assembler source files (file .s ), or preprocessed C source files (file .i ). cc automatically invokes the loader ld (unless -c is supplied). In some cases, cc generates an object file having a .o suffix and a corresponding root name. By default, output is placed in a.out . cc accepts additional system-specific options.


  • Add /usr/ccs/bin to your PATH to use the C compiler and other C Compilation System tools. This command runs the ANSI C compiler; use /usr/bin/cc if you want to run the compiler for pre-ANSI C.

  • Solaris 7 does not come with a C compiler. You must purchase one separately from Sun, or download the GNU C Compiler (GCC) from http://www.sunfreeware.com .

  • Options for cc vary wildly across Unix systems. We have chosen here to document only those options that are commonly available. You will need to check your local documentation for complete information.

  • Usually, cc passes any unrecognized options to the loader, ld .



Suppress loading and keep any object files that were produced.

-D name [= def ]

Supply a #define directive, defining name to be def or, if no def is given, the value 1 .


Run only the macro preprocessor, sending results to standard output.


Generate more symbol-table information needed for debuggers.

-I dir

Search for include files in directory dir (in addition to standard locations). Supply a -I for each new dir to be searched.

-l name

Link source file with library files lib name .so or lib name .a .

-L dir

Like -I , but search dir for library archives.

-o file

Send object output to file instead of to a.out .


Optimize object code (produced from .c or .i files).


Generate benchmark code to count the times each routine is called. File mon.out is created, so prof can be used later to produce an execution profile.


Run only the preprocessor and place the result in file .i .


Compile (and optimize, if -O is supplied), but don't assemble or load; assembler output is placed in file .s .

-U name

Remove definition of name, as if through an #undef directive.


Compile xpop.c and load it with the X libraries:

cc -o xpop xpop.c -lXaw -lXmu -lXt -lX11

Previous: Reference: cb UNIX in a Nutshell: System V Edition Next: Reference: cd
Reference: cb Book Index Reference: cd

The UNIX CD Bookshelf NavigationThe UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System