Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > questions about link

Reply
Thread Tools

questions about link

 
 
Chameleon
Guest
Posts: n/a
 
      01-17-2007
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.
 
Reply With Quote
 
 
 
 
red floyd
Guest
Posts: n/a
 
      01-17-2007
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.

 
Reply With Quote
 
 
 
 
Victor Bazarov
Guest
Posts: n/a
 
      01-17-2007
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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is D-Link DSL-604T same as D-Link DSL-604+ ? norm Wireless Networking 6 11-18-2005 10:25 AM
RE: Link Link Link =?Utf-8?B?REw=?= Windows 64bit 0 05-17-2005 12:15 PM
Re: Link Link Link DANGER WILL ROBINSON!!! Kevin Spencer ASP .Net 0 05-17-2005 10:41 AM
D-LINK DWL-AG650 doesn't work with WinXP - Zero Configuration Service (WZCSVC) / D-Link AirXpert nearly works Johannes Rosenstock Wireless Networking 0 08-27-2004 11:49 PM
Re: Questions....questions....questions Patrick Michael A+ Certification 0 06-16-2004 04:53 PM



Advertisments