Why is the compiled file size so huge?

Steven Schveighoffer schveiguy at gmail.com
Sat May 28 15:01:26 UTC 2022


On 5/27/22 9:40 AM, Alexander Zhirov wrote:
> I'm trying to compile a file that weighs 3 kilobytes. I'm also linking a 
> self-written dynamic library. I don't understand why the resulting 
> executable file is so huge? After all, all libraries are present:
> 
> ```sh
> -rwxr-xr-x 1 root root 6.3M May 27 13:39 app
> -rw-r--r-- 1 root root 2.9K May 27 12:57 app.d
> -rw-r--r-- 1 root root  25K May 27 13:39 app.o
> ```
> 

I'd say 2.9k of source is enough to produce a large binary. But looking 
at your *object file*, it shouldn't be much bigger than that, especially 
if all libs are dynamic.

Try ldc2 -v and see if there's any clues as to what else it's linking. 
You should be able also to use nm to spit out all the symbols defined in 
the binary, maybe there's some that you wouldn't expect to be there.

-Steve


More information about the Digitalmars-d-learn mailing list