473,388 Members | 1,346 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

Size of Exe file

I'm using static libraries and dynamic libraries every day.
Now I want to know when I add one static library into my project, the
libray will be all added into the final exe file, or only the part I
use is added?
Internet linkes or relative reference books are appreciated.
Thanks.
Nov 20 '08 #1
3 4473
On Nov 20, 6:35*am, "Dot.Hu" <huhang...@gmail.comwrote:
I'm using static libraries and dynamic libraries every day.
Now I want to know when I add one static library into my project, the
libray will be all added into the final exe file, or only the part I
use is added?
A .lib file is basically an archive of .o/.obj files. The linker links
in only those .obj files from the archive that define the symbols that
are unresolved in the binary being linked. In other words, if you link
against a .lib, but the binary being link does not use any of the
symbols from the .lib, that .lib is not contributing to the size of
the resulting binary.

--
Max
Nov 20 '08 #2
On Nov 20, 6:33*pm, Maxim Yegorushkin <maxim.yegorush...@gmail.com>
wrote:
On Nov 20, 6:35*am, "Dot.Hu" <huhang...@gmail.comwrote:
I'm using static libraries and dynamic libraries every day.
Now I want to know when I add one static library into my project, the
libray will be all added into the final exe file, or only the part I
use is added?

A .lib file is basically an archive of .o/.obj files. The linker links
in only those .obj files from the archive that define the symbols that
are unresolved in the binary being linked. In other words, if you link
against a .lib, but the binary being link does not use any of the
symbols from the .lib, that .lib is not contributing to the size of
the resulting binary.

--
Max
Thanks very much, Max.
I got another question.
Once one symbol is used of one .lib, then the whole .lib will be
linked into the exe?

Now I want to create some libraries, where my useful codes will
reside.
But I don't want to increase the size of .exe, because of some unused
symbols.
That's why I post this question.
Nov 21 '08 #3
Thanks very much, Max.
I got another question.
Once one symbol is used of one .lib, then the whole .lib will be
linked into the exe?
No, as Max mentionen the .lib is an archive of .obj files. The linker will
select only the subset of object files in the lib that contain symbols
referenced. Thus, unused object files will automatically be thrown away and
do not contribute to the resulting executable.

Thus, in some situation i.e. embedded development it may be worthwhile to
think about the distribution of functions to implementation (.cpp) files.
Now I want to create some libraries, where my useful codes will
reside.
But I don't want to increase the size of .exe, because of some unused
symbols.
That's why I post this question.
If you have a newer compiler chances are there is some function-level
linking option that allows the linker to on a per-function basis rather the
object files. On VC++ link-time code generation will strip the resulting
executable even further.

Regards,
Thomas.
Nov 21 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
by: Arnold | last post by:
Is using fseek and ftell a reliable method of getting the file size on a binary file? I thought I remember reading somewhere it wasn't... If not what would be the "right" and portable method to...
6
by: Andrew Clark | last post by:
*** post for FREE via your newsreader at post.newsfeed.com *** Hello all, I recall several threads over the years about how reading file size cannot be done consistantly or portably, but I...
8
by: Dave | last post by:
I am serialising an object to a memory mapped file (using the CreateFileMapping and MapViewOfFile p/invoke calls). These need to know the maximum size of the "file". I can put in a "good guess" ie...
8
by: Ron | last post by:
Hi all, How do I determine the size of the tables I'm using? I looked under properties and it's not there. The book I just browsed said table is limited to 1GB. How do I find out what size my...
5
by: Jefferis NoSpamme | last post by:
Hi all, I'm trying to limit the file size of an image submission and I keep running into various problems. I've got most of it working, but I'm stumped and I have a basic question as to WHY this...
12
by: Phil Z. | last post by:
After migrating an ASP.NET 1.1 application to 2.0 we were getting "Cannot access a closed file" errors when uploading. I found a number of post on the subject and have since moved from using an...
4
by: Doug | last post by:
Hi, It looks like the only way to get a size of a file within csharp is to use FileInfo and the Length property. However that only returns the number of bytes in the file which is translating...
1
by: chrisj | last post by:
I'm using freeASPupload and got some assistance integrating to a Member script. It works successfully. In this modified version there are two groups that use this upload script. Members of one...
20
by: Ashit Vora | last post by:
Hi, I 'm new to C programming and 'm stuck somewhere. I want to find the size of a file. I couldn't find a proper way of doing it. What I was planning to do is... Open the requested file,...
18
by: MisterE | last post by:
I hear that this isn't always valid: FILE *in; long size; in = fopen("foo.bar","rb"); fseek(in,0,SEEK_END); size = ftell(in); fseek(in,0,SEEK_SET); then fread size many bytes into memory.
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.