Are you using /opt:ref on the linker command line? you might try it if
you're not.
-sd
On Thu, 2003-05-15 at 17:43, John Stewart wrote:
> ----- Original Message -----
> From: "Neville Franks" <[EMAIL PROTECTED]>
> To: "John Stewart" <[EMAIL PROTECTED]>
> Cc: <[EMAIL PROTECTED]>
> Sent: Thursday, May 15, 2003 5:19 PM
> Subject: Re: trying to make my crypto++ using executable smaller
>
>
> > Hi John,
> > This doesn't make a lot of sense. You should be statically linking
> > Crypto++ to your code, and the linker should strip out everything you
> > aren't using. If you are using Crypto++ in a DLL then you will have
> > all of the code etc., but you shouldn't use it in a DLL.
>
> When you say it doesn't make any sense are you saying when you've used
> similar crypto++ code it has been much smaller?
>
> I am linking to crypto++ statically. My executable is a DLL but I don't
> see why that should keep the linker from only linking in the relevant code
> since I'm not exporting any part of crypto++ directly. The linker is
> definately doing something since cryptlib.lib is about 18 megs in size and
> my DLL is 450k ;) On the chance I was missing something I tried an
> experiment see the bottom of this post for details.
>
> I'll try to simplify and clarify the symptoms. The only crypto++ code
> my program uses is in the function listed below. It's straight from the
> crypto++ test program with exception handing added within the function and
> the use of the FileSource2 class. The FileSource2 class is the same as the
> FileSource class except that it uses C File I/O instead of C++ File I/O.
> Also in the DLL version the printf statements are replaced by calls to an
> error logging library that is used extensively throughout the rest of the
> program.
>
> If DO_CRYPTO is defined the resulting DLL is 450560 bytes in size. If
> it is not defined the resulting DLL is 225280 bytes in size.
>
> bool RSAVerifyFile(const char *pubFilename, const char *messageFilename,
> const char *signatureFilename)
> {
> #ifdef DO_CRYPTO
> try
> {
> FileSource2 pubFile(pubFilename, true);
> RSASSA_PKCS1v15_SHA_Verifier pub(pubFile);
>
> FileSource2 signatureFile(signatureFilename, true);
> if (signatureFile.MaxRetrievable() != pub.SignatureLength())
> return false;
> SecByteBlock signature(pub.SignatureLength());
> signatureFile.Get(signature, signature.size());
>
> VerifierFilter *verifierFilter = new VerifierFilter(pub);
> verifierFilter->Put(signature, pub.SignatureLength());
> FileSource2 f(messageFilename, true, verifierFilter);
>
> return verifierFilter->GetLastResult();
> }
> catch(CryptoPP::Exception &e)
> {
> printf("\nCryptoPP::Exception caught: %s", e.what());
> }
> catch(std::exception &e)
> {
> printf("\nstd::Exception caught: %s", e.what());
> }
> #endif
> return false;
> }
>
>
> To test the theory of the linker behaving differently when building a
> DLL as opposed to building an EXE I built a test executable including the
> above function and the below main:
> int main()
> {
> printf("result=%d\n", RSAVerifyFile("foo", "bar", "sig"));
> return 0;
> }
>
> If DO_CRYPTO is defined the size is: 286720 bytes
> If DO_CRYPTO is not defined the size is: 73728 bytes
>
> So in the case of the DLL adding the signature verification codes adds
> 225280 bytes to the size.
> And in the case of the EXE adding the signature verification codes adds
> 212992 bytes to the size.
>
> Not a huge difference there. It looks like the linker is doing an
> approximately equal job in both cases.
>
> More details:
> All reported sizes in the above are compiled with MSVC 6.0 service pack
> 5.
> Optimization setting is maximize speed.
> The run-time library option is plain old Multithreaded(not Multithreaded
> DLL). I.e. statically linked CRT.
> __cdecl calling convetion, 8 byte structure alignment and processor is
> set to the default of Blend.
>
>
>
> Thanks again,
>
> John Stewart