4.compile

4.compile - Separate compilation why how to use separately...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
Separate compilation [Bono] 1 Separate compilation •w h y • how to use separately linked code • what goes in header files • Example: separately compiled Fraction class • how to compile and link •U s i n g #ifndef
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Separate compilation [Bono] 2 Separate compilation • What it is? – put different parts of the program in different files – compile each file separately into object files link all the pieces together into one executable
Background image of page 2
Separate compilation [Bono] 3 Why separate compilation • What is it? – Compile pieces separately, then link pieces together into one executable. • Why do we do it? – separating program files increases modularity • good for team projects – separate compilation saves time: only recompile parts that changed since the last compile • on large projects, one compile can take hours – also, can save space: some systems have dynamically linked libraries : only one copy of the library in main memory shared by multiple users.
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Separate compilation [Bono] 4 Using a built-in library • When using C or C++ standard library, code is already compiled; gets linked with our code automatically. • We just have to include the necessary header file(s) • E.g.: using the math library: – Need prototype declarations from header file: #include <cmath> – Math library code will automatically get linked into executable (no special compile option necessary) g++ -Wall -ggdb myprog.cpp
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

This document was uploaded on 05/19/2010.

Page1 / 14

4.compile - Separate compilation why how to use separately...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online