Getting rid of unused Windows library code in DLL

I'm working on an application, and I want to make it as small as possible. There's no real need to do so, but I don't like big programs and I think programs should be kept as small as possible.

My program consists of a DLL or EXE file (depending on which version people download), which is currently around 700 kB in size.

When I open the DLL in a text editor, I find a lot of completely useless data, which probably means that there's a lot more that I cannot easily spot:

For example:
- A list of countries: USA, united-states, united-kingdom, trinidad & tobago, south-korea, south-africa, south korea, south africa, slovak, puerto-rico, pr-china, pr china, nz, new-zealand, hong-kong, holland, great britain, england, czech, china, britain, america, ...
- There's also one where the names start with capitals
- The name of each month in English: December, November, October, September, ...
- Also a list of abbreviated months: Dec, Nov, Oct, Sep, Aug, Jul, ...
- The days of the week, also full names and abbreviations
- A concatenated list of all days of the week and one for each month
- Strange errors like: "This application cannot run using the active version of the Microsoft .NET Runtime" (this is a NATIVE C++ binary!)
- Texts like "Usage: %s segment_size input_file [-trace]", which appear to be command line messages for applications (not mine though!)

All of this doesn't seem to be really useful, and it's using space. Is there a way to get rid of this?

I'm using MS Visual Studio 2003 with Intel C++ Compiler 10.1. (Yes, that's not the latest version - but built with this version my software performs over 20% better than with newer versions). The build is a release build, all relevant optimizations have been enabled. (I suppose it's a linking issue)
Last edited on
How are you compiling your program? Could it be you are simply linking libraries that you don't need?
Probably. The thing is, I'm using MFC which requires a lot of libraries. All the relevant optimizations have been enabled - which means that functions that I don't use should not be included. (I'm also including other VERY BIG libraries, which only increase the file size a bit because only a small part is included in the final DLL/EXE file). But in this case, all this stuff is still included. Which _should_ mean that the linker "thinks" I need it.
To be honest - if you want to completely prevent garbage in your program, I am afraid you will have to write your programs in assembly. There is a limit to what your linker can optimize out.
That might be true :-(

By now I found out that this code is coming from a file called libcmt.lib. I've checked all the files that are linked, and this is the only one that contains the code that I don't need.
And, do you need this library? From what I can tell, it seems to be related to multithreading.
I am using multiple threads. Anyway, libc.lib contains the same code, so I would need to get rid completely of libc(mt).lib - which seems to be nearly impossible for MFC projects.

Maybe I can get another libcmt.lib from another compiler and use that (but that sounds VERY tricky).
Last edited on
Probably you can't. lib files are usually compiler specific.
Isn't libcmt the mt version of libc, so you'd expect functions of the same name right? As it happens, they both have those strings you don't like.

BTW, there's also debug versions of these (libcd and libcmtd).
Topic archived. No new replies allowed.