static and dynamic

This is a discussion on static and dynamic within the C Programming forums, part of the General Programming Boards category; what is the difference between static and dynamically linked programs, and how do I link them in the different modes? ...

  1. #1
    Obsessed with C chrismiceli's Avatar
    Join Date
    Jan 2003
    Posts
    501

    static and dynamic

    what is the difference between static and dynamically linked programs, and how do I link them in the different modes? I use gcc.

  2. #2
    Registered User
    Join Date
    Jan 2003
    Posts
    88
    dynamic linking will make use of existing libraries. for example if the definition of sin() is in libmath the program will use the libmath on your computer and not include the definition in it self. thus the program is smaller. however if something is corrupted/damaged with libmath your program will not be able to use that function.

    static linking takes the definition of sin() out of libmath and inserts it into your program so that no matter if libmath is deleted or damaged your program will have that definition in itself and is not affected. thus the program is bigger.

    static linking is more used for "mission-critical" programs where one would not need to worry about the version of the library on your system or it's location. dynamic linking is the opposite.

    make sure you do not violate copyright laws with static linking. for example if a library is created and licensed under the LGPL and you are creating a proprietary/closed program (ewwwww...) you cannot static link because that would take the LGPL'ed code and insert it into the closed application...

    man gcc should give you everything you need.

    hope this helps.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need a refresher, the difference between static and dynamic.
    By indigo0086 in forum C++ Programming
    Replies: 6
    Last Post: 06-27-2008, 02:28 AM
  2. Replies: 19
    Last Post: 01-12-2006, 10:04 AM
  3. dynamic or static binding
    By noob2c in forum C++ Programming
    Replies: 1
    Last Post: 08-06-2003, 01:43 PM
  4. static memory and dynamic memory
    By nextus in forum C++ Programming
    Replies: 1
    Last Post: 03-01-2003, 07:46 PM
  5. Static Binding & Dynamic Binding :: C++
    By kuphryn in forum C++ Programming
    Replies: 2
    Last Post: 12-31-2001, 07:51 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21