Linking + size

This is a discussion on Linking + size within the C++ Programming forums, part of the General Programming Boards category; When you link a library in the linking settings and you will compile a file (not a project) that doesnt ...

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

    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.
    Compiler MSVC++ 2013 with Code::Blocks.

  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
    812
    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.
    Compiler MSVC++ 2013 with Code::Blocks.

  4. #4
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    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, 10:57 AM
  2. Heapsort
    By xENGINEERx in forum C Programming
    Replies: 2
    Last Post: 03-30-2008, 08: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, 04:06 PM
  5. linking errors
    By sentienttoaster in forum C++ Programming
    Replies: 4
    Last Post: 11-30-2003, 03:01 PM

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