How to reduce the size of the program?
-
I have a small program, but to run it on another computer, you must send it with 80 mb of libraries(*.dll). I'm sure that I do not use them all. How do I reduce their quantity, well, or at least merge them with the *.exe?
Thank you. -
welcome to devnet
In order to find out which dll is required you can use on windows dependency walker.
You find some "details here":http://qt-project.org/wiki/Show_library_dependencies#aea23489ce3aa9b6406ebb28e0cda430 -
You may also apply an "EXE Packer" such as the widely-used UPX:
http://upx.sourceforge.net/Though, if you distribute your files in a compressed archive with a good compressor (e.g. 7-Zip) anyway, this won't make much of a difference, except that the un-archived program will take less space on the HDD.
--
Anyway, definitely use Dependency Walker to see what DLL's your program actually depends on:
http://www.dependencywalker.com/Then kick out all DLL's that your program doesn't use. But make sure you use the "profiling" feature of Dependency Walker on your program, because only this way Plug-in DLL's can be picked up...
--
Last but not least, if possible License-wise, you can build your application with the static Qt libraries, which can further reduce the overall size, compared to using Qt as separate DLL's. Of course only if you have a single EXE file. As soon as you have several EXE files, using Qt as shared DLL's is more space efficient.
-
Keep in mind dependency walker doesn't catch all the dependencies - only compile time, Qt applications will still load and resolve dlls dynamically, and if those are missing, you won't get not error no notice, just an application that does not run when started.
-
[quote author="utcenter" date="1365979267"]Keep in mind dependency walker doesn't catch all the dependencies - only compile time, Qt applications will still load and resolve dlls dynamically, and if those are missing, you won't get not error no notice, just an application that does not run when started.[/quote]
It does catch all DLL's, if you use the "Profiling" feature. That's why I suggested using it. Nonetheless not all Plug-in DLL's that Qt will find and load at run-time will absolute be necessary. For example, Qt will load all image format plug-in's it finds. But if you don't need some image formats, your program will work just fine without the corresponding extra plug-in DLL's. You won't get around deciding which plug-in's you need manually.
-
Unfortunately Dependency Walker began to show some strange library, so I had to copy all the libraries and removing some of them to find out which ones are needed for the program.
But now the total size of DLL 36,2 mb, and now the size is not a problem. Is it worth try to merge all dll and exe to exe? -
[quote author="De_Broglie" date="1366026134"]Unfortunately Dependency Walker began to show some strange library, so I had to copy all the libraries and removing some of them to find out which ones are needed for the program.[/quote]
Not quite sure what you mean. Can you share a screenshort?
(BTW: I would recommend to configure Dependency Walker to show full paths)
[quote author="De_Broglie" date="1366026134"]But now the total size of DLL 36,2 mb, and now the size is not a problem. Is it worth try to merge all dll and exe to exe?[/quote]
If with that you mean "static linking", yes, it's definitely worth a try, if your application is a single EXE and if your license allows for static linking. If the Qt libraries are linked statically, the Linker can optimized (throw out) all the functions and/or classes that are never referenced in your program. And as Qt is a rather big (feature-rich) framework, chances are good your program only needs a small subset of it. With DLL's that's not possible. When building Qt as DLL's, you always get a complete Qt, as the Linker cannot know which functions the program is going to call. It cannot optimize out anything (except maybe for some code that is unreachable/dead anyway).