0% found this document useful (0 votes)
9 views2 pages

C Programming Basics in UNIX

C programming within UNIX allows developers to: 1. Write C source code using text editors, compile it to create executable files, and run the programs. 2. Compile modules separately and link them together, allowing debugging and code reuse. 3. Use makefiles and the make utility to automate rebuilding when dependencies change, tracking interdependencies between source files.

Uploaded by

sug14#
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views2 pages

C Programming Basics in UNIX

C programming within UNIX allows developers to: 1. Write C source code using text editors, compile it to create executable files, and run the programs. 2. Compile modules separately and link them together, allowing debugging and code reuse. 3. Use makefiles and the make utility to automate rebuilding when dependencies change, tracking interdependencies between source files.

Uploaded by

sug14#
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

C Programming within UNIX

- UNIX written in C or C++, so basic C compiler usually built in


- not a complete IDE like Borland, but functional and clean
(p. 339)

steps:
1. create source code with text editor (vi, pico)
- best to use the suffix .c to indicate that it is a C program
- then compiler looks for this kind of program

2. to compile, cc programname.c

- get error messages if they exist


go back to editor and correct source and recompile
- no output if compiles properly
and the executable file [Link] is created

3. to run, [Link] this is the name of the file created by the


compiler
- loads and runs the program

- to specify the name of the output file from the compiler

cc programname.c -o new_file_name
e.g.
cc addition.c -o add

UNIX can let you compile modules separately and then load as one
program
- lets you debug and reuse modules

cc -c addition.c (produces addition.o)


cc -c divide.c (gives divide.o)
- then you link them together into one executable

cc addition.o divide.o main

UNIX gives you tools to maintain your modules


- lets you know which have to be recompiled if any
dependencies are changed

make [-f makefile]

- keeps a list of things which have changed and need to be redone

- need to create a makefile with all the interdependencies that


exist between files

targetList:dependencyList
commandList

- build up a tree of interdependencies

- to force the make process, can update the last modified times to the
present with

touch -c {fileName}

Source Code Control System: SCCS

- UNIX scheme to administer large projects with various


authors and versions
- lets you “sign-out” code to modify and tracks what is
happening and when
- use the admin utility to maintain the SCCS information
- can provide a history of changes
- supports version control, locking releases

You might also like