Question

I have created a DLL file (library) with one assembler function. This file is 75kB size. How to make this file smaller? Like I suspect, there is an automatically included System unit. Can I exclude this unit from my dll file?

Was it helpful?

Solution

I googled your Issue, as it came to my mind in Visual C++ there are Debug&Release Modes. So maybe you can try creating a smaller Dll using the Release Mode. I found some settings for this: http://bugs.freepascal.org/bug_view_advanced_page.php?bug_id=18632
Maybe this helps you, but I'm not sure it will work because I didn't work with Pascal for like 2 years :)

OTHER TIPS

  1. Why? are you concerned about binary sizes on one hand, and have a 64-bit tag on the other?

  2. Debug info, pass -Xs to strip debuginfo

  3. Smartlinking, pass -XX (dead code elimination) 1+2 combines to -XXs

  4. Avoid advanced functionality. Do NOT set any $Mode, the delphi compatible additions to system will bulk it up.

If you want to further reduce you will have to edit the RTL source and recompile it.

You can also try UPX to pack your DLL-s. I recently made a simple DLL in Delphi and here are some observations I made:

1) Delphi 7 made almost 2 times smaller file than Delphi XE3 (32bit, Release mode). Lazarus made the biggest file. So maybe older FPC can make smaller file?

2) I stripped all non-mine units from the library. I even replaced Math and Windows with my own, super-short versions. This reduced the file size about twice.

3) System unit is something you can't just remove, but there are ways to create your own, recompile and replace. I guess this is also possible with Lazarus/FPC.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top