Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Which one makes for faster programs: DLLs or static libraries???

Which one makes for faster programs: DLLs or static libraries???

Scheduled Pinned Locked Moved C / C++ / MFC
question
8 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mwhannan
    wrote on last edited by
    #1

    This might seem like a trival question, but does a dll or static lib generate faster code? My guess would be static lib, but I really do not know much about dll's. The reason that I ask is that I am writing a bunch of realtime code and I need to make things as fast as possible. Also, how does one choose when to use a dll or a lib? Thanks

    W A C 3 Replies Last reply
    0
    • M mwhannan

      This might seem like a trival question, but does a dll or static lib generate faster code? My guess would be static lib, but I really do not know much about dll's. The reason that I ask is that I am writing a bunch of realtime code and I need to make things as fast as possible. Also, how does one choose when to use a dll or a lib? Thanks

      W Offline
      W Offline
      winalice
      wrote on last edited by
      #2

      The small one, I think.

      1 Reply Last reply
      0
      • M mwhannan

        This might seem like a trival question, but does a dll or static lib generate faster code? My guess would be static lib, but I really do not know much about dll's. The reason that I ask is that I am writing a bunch of realtime code and I need to make things as fast as possible. Also, how does one choose when to use a dll or a lib? Thanks

        A Offline
        A Offline
        alex barylski
        wrote on last edited by
        #3

        I think that would be compiler and programmer dependant. You as the programmer have most control over code speed... :) However lib's are probably quicker because everything is linked at compile time and theres no additional over head for linking to an external library at runtime. Other than that:

        int b=0;

        for(int i=0; i<10; i++)
        b=(b*i)+1;

        I would think would compile into the same instructions regardless of output file being DLL or LIB :) mwhannan wrote: Also, how does one choose when to use a dll or a lib? LIB's are usually passed around when you as the programmer wants differ modules of functionality, but in the finalized product you want one single exe...DLL's are used for keeping final product in seperate modules...making it easy to upgrade parts of your app but only updating a single file... One is runtime and the other is compile time linkage. Cheers :) I'm drinking triples, seeing double and acting single :cool:

        M 1 Reply Last reply
        0
        • A alex barylski

          I think that would be compiler and programmer dependant. You as the programmer have most control over code speed... :) However lib's are probably quicker because everything is linked at compile time and theres no additional over head for linking to an external library at runtime. Other than that:

          int b=0;

          for(int i=0; i<10; i++)
          b=(b*i)+1;

          I would think would compile into the same instructions regardless of output file being DLL or LIB :) mwhannan wrote: Also, how does one choose when to use a dll or a lib? LIB's are usually passed around when you as the programmer wants differ modules of functionality, but in the finalized product you want one single exe...DLL's are used for keeping final product in seperate modules...making it easy to upgrade parts of your app but only updating a single file... One is runtime and the other is compile time linkage. Cheers :) I'm drinking triples, seeing double and acting single :cool:

          M Offline
          M Offline
          mwhannan
          wrote on last edited by
          #4

          "However lib's are probably quicker because everything is linked at compile time and theres no additional over head for linking to an external library at runtime." That was what I was thinking. Does "at run time" mean that it is linked when the program first starts up, or it can happen any time during program execution? "LIB's are usually passed around when you as the programmer wants differ modules of functionality, but in the finalized product you want one single exe...DLL's are used for keeping final product in seperate modules...making it easy to upgrade parts of your app but only updating a single file..." Thanks, that help clear some things up.

          A 1 Reply Last reply
          0
          • M mwhannan

            "However lib's are probably quicker because everything is linked at compile time and theres no additional over head for linking to an external library at runtime." That was what I was thinking. Does "at run time" mean that it is linked when the program first starts up, or it can happen any time during program execution? "LIB's are usually passed around when you as the programmer wants differ modules of functionality, but in the finalized product you want one single exe...DLL's are used for keeping final product in seperate modules...making it easy to upgrade parts of your app but only updating a single file..." Thanks, that help clear some things up.

            A Offline
            A Offline
            alex barylski
            wrote on last edited by
            #5

            mwhannan wrote: Does "at run time" mean that it is linked when the program first starts up, or it can happen any time during program execution? Can be either...basically at programmers preference instead of complier Cheers :) I'm drinking triples, seeing double and acting single :cool:

            M 1 Reply Last reply
            0
            • A alex barylski

              mwhannan wrote: Does "at run time" mean that it is linked when the program first starts up, or it can happen any time during program execution? Can be either...basically at programmers preference instead of complier Cheers :) I'm drinking triples, seeing double and acting single :cool:

              M Offline
              M Offline
              mwhannan
              wrote on last edited by
              #6

              "Can be either...basically at programmers preference instead of complier " How does that work? Sorry if these are annoying questions.

              M 1 Reply Last reply
              0
              • M mwhannan

                This might seem like a trival question, but does a dll or static lib generate faster code? My guess would be static lib, but I really do not know much about dll's. The reason that I ask is that I am writing a bunch of realtime code and I need to make things as fast as possible. Also, how does one choose when to use a dll or a lib? Thanks

                C Offline
                C Offline
                cmk
                wrote on last edited by
                #7

                You missed another distinction : static link dll's (bound at compile time) and dynamic link dll's (loaded at run time). Regardless, the time differences between the 3 are generally orders of magnitude less than the time an actual function takes to run. There are also other effects that are out of the control of the application that would make measuring such differences difficult. e.g. just because the static lib is linked into the exe doesn't mean the code is in physical memory - it may be paged out, whereas a dll that's shared amongst several (running) programs may have a better chance of having it's code in physical memory at any given time. ...cmk Save the whales - collect the whole set

                1 Reply Last reply
                0
                • M mwhannan

                  "Can be either...basically at programmers preference instead of complier " How does that work? Sorry if these are annoying questions.

                  M Offline
                  M Offline
                  melwyn
                  wrote on last edited by
                  #8

                  The dll is loaded by the client whenever the LoadLibrary() API is invoked by the client.

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups