questions about link

Discussion in 'C++' started by Chameleon, Jan 17, 2007.

  1. Chameleon

    Chameleon Guest

    My project uses many libraries like libjpeg, libpng and more.
    With all of these libraries linked statically and with many .cpp files
    of my project, a big binary executable is predictable.

    I'm impressed when I was remove the code inside 'main(...)' and all of
    the includes, but executable size doesn't change, at all.

    There are many *.cpp files but in test.cpp which implements 'main' there
    is only this code:
    ----test.cpp--------
    int main(int argc, char **argv)
    {
    return 0;
    }
    --------------------

    size for this executable is about 290KBs and inside binary I recognize
    parts of zlib library. I use zlib library in other .cpp file than
    test.cpp, but I don't call anything from this file and if I remove it,
    all work ok and size decreases.
    If I remove all files except test.cpp, it compiles fine and size is 10KBs.

    So the question is why linker include useless binary objects to final
    binary executable.

    My compiler/linker is mingw-g++, if does matter.
    Chameleon, Jan 17, 2007
    #1
    1. Advertising

  2. Chameleon

    red floyd Guest

    Chameleon wrote:
    > [redacted]


    Linker behavior is not defined by the language, as well as being
    tool-specific, and is thus off-topic of this newsgroup.

    >
    > My compiler/linker is mingw-g++, if does matter.


    Yes, it does, it allows me to direct you to the proper newsgroup. Try
    gnu.g++.help.
    red floyd, Jan 17, 2007
    #2
    1. Advertising

  3. Chameleon wrote:
    > My project uses many libraries like libjpeg, libpng and more.
    > [..executable size depends on libraries linked to..]
    > So the question is why linker include useless binary objects to final
    > binary executable.
    >
    > My compiler/linker is mingw-g++, if does matter.


    The language does not define how libraries are linked to, and what
    the resulting executable size should be. Your question is not really
    possible to asnwer in terms of the language. Your best bet is to ask
    in the newsgroup dedicated to your compiler/linker or your OS (where
    linking is actually defined). My guess would be that the library has
    some static objects which get inserted in your executable and their
    presence requires a bunch of object modules to be pulled in...

    V
    --
    Please remove capital 'A's when replying by e-mail
    I do not respond to top-posted replies, please don't ask
    Victor Bazarov, Jan 17, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kevin Spencer

    Re: Link Link Link DANGER WILL ROBINSON!!!

    Kevin Spencer, May 17, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    800
    Kevin Spencer
    May 17, 2005
  2. Graham Thomson
    Replies:
    3
    Views:
    446
    Eki Y. Baskoro
    Dec 18, 2003
  3. Dan M
    Replies:
    5
    Views:
    412
  4. kolesdz
    Replies:
    9
    Views:
    519
    Blinky the Shark
    Aug 22, 2007
  5. Marina Limeira

    LINK with another link

    Marina Limeira, Feb 7, 2006, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    106
    Marina Limeira
    Feb 7, 2006
Loading...

Share This Page