Thread: Linking + size

  1. #1
    Registered User
    Join Date
    Dec 2007
    Posts
    930

    Linking + size

    When you link a library in the linking settings and you will compile a file (not a project)
    that doesnt need this library, will it still compile the library with the file or only will do so if it needs it?

    Im asking this because if you have a few libraries set, it could raise both the size and the compile time.

    Im using codeblocks with VC 2008 and it doesnt seem to have augmented the size of the executable.
    Using Windows 10 with Code Blocks and MingW.

  2. #2
    Student legit's Avatar
    Join Date
    Aug 2008
    Location
    UK -> Newcastle
    Posts
    156
    If you link it, then it will compile it. (I Think)
    MSDN <- Programmers Haven!

  3. #3
    Registered User
    Join Date
    Dec 2007
    Posts
    930
    Yes thats what i thought too.

    Thats why its better to use pragma comment, that way you dont need to create a project for every little file you compile.
    Using Windows 10 with Code Blocks and MingW.

  4. #4
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    I suppose you can always test it out to be sure (add some extra libraries in your command line, see if the size changes). If you're linking statically, for whatever reason my belief was always that only the code you used was linked in.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. size of array
    By goran00 in forum C Programming
    Replies: 38
    Last Post: 04-02-2008, 09:57 AM
  2. Heapsort
    By xENGINEERx in forum C Programming
    Replies: 2
    Last Post: 03-30-2008, 07:17 PM
  3. Generic heapsort
    By Sephiroth1109 in forum C Programming
    Replies: 15
    Last Post: 12-07-2007, 06:14 PM
  4. An exercise in optimization
    By Prelude in forum Contests Board
    Replies: 10
    Last Post: 04-29-2005, 03:06 PM
  5. linking errors
    By sentienttoaster in forum C++ Programming
    Replies: 4
    Last Post: 11-30-2003, 03:01 PM