CEG 221 Lesson 6: Using - PowerPoint PPT Presentation

About This Presentation
Title:

CEG 221 Lesson 6: Using

Description:

Why build libraries? How to build libraries. Using Libraries. Tradeoffs. Questions ... They hide the headers/interface (how to use) from the source ... – PowerPoint PPT presentation

Number of Views:75
Avg rating:3.0/5.0
Slides: 10
Provided by: david91
Category:
Tags: ceg | build | how | lesson | to | using

less

Transcript and Presenter's Notes

Title: CEG 221 Lesson 6: Using


1
CEG 221Lesson 6 Using Building Libraries
  • Mr. David Lippa

2
Overview
  • Building Libraries
  • What are libraries?
  • Why build libraries?
  • How to build libraries
  • Using Libraries
  • Tradeoffs
  • Questions

3
What are libraries?
  • A library is a collection of data structures and
    functions that are grouped together by relevance
    with a specific purpose in mind
  • Precompiled library a header file containing
    function prototypes and a .LIB file consisting of
    their function bodies the header file is said to
    be the interface
  • kernel32.lib is a precompiled library of routines
    and structures used to make an application run
    under 32-bit Windows
  • Uncompiled library a library consisting of
    header files (.h) and C source files (.c)
  • stdio.h is an uncompiled library of structures
    (FILE) and functions (printf, scanf, etc.) for
    user input/output

4
Why Build Libraries?
  • They add an extra layer to modular programming
    a module that is a collection of modules
  • They are portable (cross-platform) when
    distributed as source files and let you build
    them on whatever platform (OS) is needed with
    whatever compiler
  • They hide the headers/interface (how to use) from
    the source/implementation (the actual work)

5
Precompiled Libraries
  • Precompiled libraries come with a .LIB file and
    header files that specify how to use the library
  • They are platform-specific it must be properly
    compiled on the same processor type (ie. x86),
    OS, and compiler
  • They need to be linked with your application, and
    their header files must be included in the project

6
Uncompiled Libraries
  • Uncompiled libraries come with complete source
    code
  • Consists of header files (.h) which consist of
    data structures and function prototypes
    (interface) and source files (.c) which consist
    of function bodies (implementation)
  • They either need to be
  • compiled into a .LIB file and then linked
  • included in the project with the rest of your
    source files

7
Examples
  • Libraries of Libraries Red Hat Linux an OS
    that has libraries and header files built into
    the operating system to build the next version of
    that operating systemx
  • JPG, HDF Libraries for importing images
  • Windowing Toolkits (QT, MFC) for building
    Graphical User Interfaces and applications
  • Groupware Toolkits for building
    Groupware/collaboration applications
  • Precompiled Library Demo Integration

8
Advantages and Disadvantages
  • Precompiled
  • PROS Just link, add header files, and run!
  • CONS Compiler, Processor, and OS-specific
  • Uncompiled
  • PROS cross-platform, easier to debug
  • CONS more difficult to use difficult to debug
    if it fails to compile
  • When looking for a library, it is typically best
    to get a precompiled library for a novice user
  • Both types typically come with documentation on
    how to use the library and what each function does

9
Questions?
Write a Comment
User Comments (0)
About PowerShow.com