Discussion:
[cryptopp-users] Reduce Static Lib Size on Windows
Mohamed Sherief
2018-11-06 01:51:02 UTC
Permalink
Hi Crypto++ Users,

I obtained the latest release of Crypto++ 7.0 from
https://www.cryptopp.com/#lists.

I was able to compile it using Visual Studio 2017, and generate
cryptlib.lib for static linking, and it works properly. The release version
size is 36,805 KB with the following optimization options:

- No Whole Program Optimization.
- Favor Size /O1
- Savor small code /Os
- Complete command options: "/Yu"pch.h" /GS /W4 /wd"4231" /wd"4251"
/wd"4275" /wd"4355" /wd"4505" /Gy /Zc:wchar_t /Zi /Gm- /O1 /Ob2
/Fd"x64\cryptlib\Release\cryptlib.pdb" /Zc:inline /fp:precise /D "NDEBUG"
/D "USE_PRECOMPILED_HEADERS" /errorReport:none /GF /WX- /Zc:forScope /Gd
/Oy /Oi /MT /FC /Fa"x64\cryptlib\Release\" /EHsc /nologo
/Fo"x64\cryptlib\Release\" /Os /Fp"x64\cryptlib\Release\cryptlib.pch"
/diagnostics:classic"


I am interested in AES encryption/decryption only, and the size +36 MB is
very big relative to the limited functionality that I am interested in. My
questions are:

- Do you suggest any changes to my build command for smaller size?
- Is it possible to exclude the functionalities that I am not interested
in, and keep AES only for having a smaller size?


Thanks,
Mohamed.
--
You received this message because you are subscribed to "Crypto++ Users". More information about Crypto++ and this group is available at http://www.cryptopp.com and http://groups.google.com/forum/#!forum/cryptopp-users.
---
You received this message because you are subscribed to the Google Groups "Crypto++ Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cryptopp-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Jean-Pierre Münch
2018-11-06 09:15:27 UTC
Permalink
Hi Mohammed,

a few options for you (in order from most to least work intense):

* "Don't care". The static library is 37MB, but for your actual end
result the linker should only pick the parts it actually needs which
should cut the size naturally and on your development machine, it
shouldn't really matter how big the files are.
* Enable Whole Program Optimization. Essentially this tells the
optimizer that it may look beyond function or file boundaries which
should enable it to possibly apply some better optimizations.
* Iteratively remove files from the project until it stops working.
While Crypto++ has quite a bit of support code, eg for secure memory
management, you can probably safely remove source files belonging to
eg Skein or SHA3.

I hope this will solve your issues.

BR

JPM
Post by Mohamed Sherief
Hi Crypto++ Users,
I obtained the latest release of Crypto++ 7.0 from
https://www.cryptopp.com/#lists.
I was able to compile it using Visual Studio 2017, and generate
cryptlib.lib for static linking, and it works properly. The release
* No Whole Program Optimization.
* Favor Size /O1
* Savor small code /Os
* Complete command options: "/Yu"pch.h" /GS /W4 /wd"4231" /wd"4251"
/wd"4275" /wd"4355" /wd"4505" /Gy /Zc:wchar_t /Zi /Gm- /O1 /Ob2
/Fd"x64\cryptlib\Release\cryptlib.pdb" /Zc:inline /fp:precise /D
"NDEBUG" /D "USE_PRECOMPILED_HEADERS" /errorReport:none /GF /WX-
/Zc:forScope /Gd /Oy /Oi /MT /FC /Fa"x64\cryptlib\Release\" /EHsc
/nologo /Fo"x64\cryptlib\Release\" /Os
/Fp"x64\cryptlib\Release\cryptlib.pch" /diagnostics:classic"
I am interested in AES encryption/decryption only, and the size +36 MB
is very big relative to the limited functionality that I am interested
* Do you suggest any changes to my build command for smaller size?
* Is it possible to exclude the functionalities that I am not
interested in, and keep AES only for having a smaller size?
Thanks,
Mohamed.
--
You received this message because you are subscribed to "Crypto++
Users". More information about Crypto++ and this group is available at
http://www.cryptopp.com and
http://groups.google.com/forum/#!forum/cryptopp-users.
---
You received this message because you are subscribed to the Google
Groups "Crypto++ Users" group.
To unsubscribe from this group and stop receiving emails from it, send
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to "Crypto++ Users". More information about Crypto++ and this group is available at http://www.cryptopp.com and http://groups.google.com/forum/#!forum/cryptopp-users.
---
You received this message because you are subscribed to the Google Groups "Crypto++ Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cryptopp-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Mohamed Sherief
2018-11-06 17:26:32 UTC
Permalink
Thanks Jean! Your answer is helpful.
Post by Jean-Pierre Münch
Hi Mohammed,
- "Don't care". The static library is 37MB, but for your actual end
result the linker should only pick the parts it actually needs which should
cut the size naturally and on your development machine, it shouldn't really
matter how big the files are.
- Enable Whole Program Optimization. Essentially this tells the
optimizer that it may look beyond function or file boundaries which should
enable it to possibly apply some better optimizations.
- Iteratively remove files from the project until it stops working.
While Crypto++ has quite a bit of support code, eg for secure memory
management, you can probably safely remove source files belonging to eg
Skein or SHA3.
I hope this will solve your issues.
BR
JPM
Hi Crypto++ Users,
I obtained the latest release of Crypto++ 7.0 from
https://www.cryptopp.com/#lists.
I was able to compile it using Visual Studio 2017, and generate
cryptlib.lib for static linking, and it works properly. The release version
- No Whole Program Optimization.
- Favor Size /O1
- Savor small code /Os
- Complete command options: "/Yu"pch.h" /GS /W4 /wd"4231" /wd"4251"
/wd"4275" /wd"4355" /wd"4505" /Gy /Zc:wchar_t /Zi /Gm- /O1 /Ob2
/Fd"x64\cryptlib\Release\cryptlib.pdb" /Zc:inline /fp:precise /D "NDEBUG"
/D "USE_PRECOMPILED_HEADERS" /errorReport:none /GF /WX- /Zc:forScope /Gd
/Oy /Oi /MT /FC /Fa"x64\cryptlib\Release\" /EHsc /nologo
/Fo"x64\cryptlib\Release\" /Os /Fp"x64\cryptlib\Release\cryptlib.pch"
/diagnostics:classic"
I am interested in AES encryption/decryption only, and the size +36 MB is
very big relative to the limited functionality that I am interested in. My
- Do you suggest any changes to my build command for smaller size?
- Is it possible to exclude the functionalities that I am not
interested in, and keep AES only for having a smaller size?
Thanks,
Mohamed.
--
You received this message because you are subscribed to "Crypto++ Users".
More information about Crypto++ and this group is available at
http://www.cryptopp.com and
http://groups.google.com/forum/#!forum/cryptopp-users.
---
You received this message because you are subscribed to the Google Groups
"Crypto++ Users" group.
To unsubscribe from this group and stop receiving emails from it, send an
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to "Crypto++ Users". More information about Crypto++ and this group is available at http://www.cryptopp.com and http://groups.google.com/forum/#!forum/cryptopp-users.
---
You received this message because you are subscribed to the Google Groups "Crypto++ Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cryptopp-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...