How to reduce the size of both a release and debug  Microsoft Visual Studio 2008 C++ 64 bit static library, OpenSSL,  compiled with MT and MD?

camster123
camster123 used Ask the Experts™
on
I wish to reduce the size of both a release and debug  Microsoft Visual Studio 2008 64 bit static library, OpenSSL,  compiled with MT and MD separately. I read that the /01 option is really guaranteed  to make the code smaller and that you have to set /LTCG and /GL to No to shrink  the size of the release C++ static library. Also, I read that there is another setting in the the General properties called "No Whole Program Optimization" which might shrink the static  library size.
   Before I try these things which I read, I wish to determine if they are correct and whether there any another Microsoft Visual Studio 2008 compiler and linker options I should try to reduce the size of both the release and debug Microsoft VIsual Studio 2008 C++ OPenSSL static library compiled with MT and MD separately.

Here is my OpenSSL makefile. Please correct it so i can reduce the size of both a release and debug  Microsoft Visual Studio 2008 C++ 64-bit static library, OpenSSL,  compiled with MT and MD

 This makefile has been automatically generated from the OpenSSL distribution.
# This single makefile will build the complete OpenSSL distribution and
# by default leave the 'intertesting' output files in .\out and the stuff
# that needs deleting in .\tmp.
# The file was generated by running 'make makefile.one', which
# does a 'make files', which writes all the environment variables from all
# the makefiles to the file call MINFO.  This file is used by
# util\mk1mf.pl to generate makefile.one.
# The 'makefile per directory' system suites me when developing this
# library and also so I can 'distribute' indervidual library sections.
# The one monster makefile better suits building in non-unix
# environments.

INSTALLTOP=\usr\local\ssl

# Set your compiler options
PLATFORM=VC-WIN64A
CC=cl
CFLAG= /Z7 /MTd /Ox /W3 /Gs0 /GF /Gy /nologo -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -DDSO_WIN32 -DOPENSSL_SYSNAME_WIN32 -DOPENSSL_SYSNAME_WINNT -DUNICODE -D_UNICODE -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE /Fdout32 -DOPENSSL_NO_IDEA -DOPENSSL_NO_CAMELLIA -DOPENSSL_NO_SEED -DOPENSSL_NO_RC5 -DOPENSSL_NO_MDC2 -DOPENSSL_NO_CMS -DOPENSSL_NO_JPAKE -DOPENSSL_NO_CAPIENG -DOPENSSL_NO_KRB5 -DOPENSSL_NO_DYNAMIC_ENGINE    
APP_CFLAG=
LIB_CFLAG=/Zl
SHLIB_CFLAG=
APP_EX_OBJ=setargv.obj
SHLIB_EX_OBJ=
# add extra libraries to this define, for solaris -lsocket -lnsl would
# be added
EX_LIBS=wsock32.lib gdi32.lib crypt32.lib advapi32.lib user32.lib

# The OpenSSL directory
SRC_D=.

LINK=link
LFLAGS=/nologo /subsystem:console /opt:ref
RSC=rc
FIPSLINK=$(PERL) util\fipslink.pl

AES_ASM_OBJ=
AES_ASM_SRC=
BN_ASM_OBJ=
BN_ASM_SRC=
BNCO_ASM_OBJ=
BNCO_ASM_SRC=
DES_ENC_OBJ=
DES_ENC_SRC=
BF_ENC_OBJ=
BF_ENC_SRC=
CAST_ENC_OBJ=
CAST_ENC_SRC=
RC4_ENC_OBJ=
RC4_ENC_SRC=
RC5_ENC_OBJ=
RC5_ENC_SRC=
MD5_ASM_OBJ=
MD5_ASM_SRC=
SHA1_ASM_OBJ=
SHA1_ASM_SRC=
RMD160_ASM_OBJ=
RMD160_ASM_SRC=
CPUID_ASM_OBJ=
CPUID_ASM_SRC=

# The output directory for everything intersting
OUT_D=out64Z7MTd
# The output directory for all the temporary muck
TMP_D=tmp64Z7MTd
# The output directory for the header files
INC_D=inc64Z7MTd
INCO_D=inc64Z7MTd\openssl

PERL=perl
CP=$(PERL) util/copy.pl
RM=del /Q
RANLIB=
MKDIR=$(PERL) util/mkdir-p.pl
MKLIB=lib /nologo
MLFLAGS=
ASM=ml /nologo /Cp /coff /c /Cx

# FIPS validated module and support file locations

E_PREMAIN_DSO=fips_premain_dso

FIPSLIB_D=\usr\local\ssl\fips-1.0\lib
BASEADDR=0xFB00000
FIPS_PREMAIN_SRC=$(FIPSLIB_D)\fips_premain.c
O_FIPSCANISTER=$(FIPSLIB_D)\fipscanister.lib
FIPS_SHA1_EXE=
PREMAIN_DSO_EXE=$(BIN_D)\fips_premain_dso.exe

######################################################
# You should not need to touch anything below this point
######################################################

E_EXE=openssl
SSL=ssleay32
CRYPTO=libeay32
LIBFIPS=libosslfips


Thank you very much,.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
camster123Senior C++ Software Engineer

Author

Commented:
Good morning everybody,
  This Experts Exchange has some good hints on how to reduce the size of a Visual Studio static library,

http://www.experts-exchange.com/Programming/Languages/.NET/Visual_CPP/Q_25788952.html

Thank you.
Top Expert 2012
Commented:
/O1 is indeed the way to go. owever, it only makes sense for release builds, you don't want to use this for a debug build, since it - as well as any other optimization - defies the purpose of the latter.

You basically add it to 'CFLAG', replacing all '/G*' flags. See also https://msdn.microsoft.com/en-us/library/8f8h5cxt.aspx ("/O1, /O2 (Minimize Size, Maximize Speed)")
camster123Senior C++ Software Engineer

Author

Commented:
jkr, Thank you very much for your help.  Please tell me how to test if the openssl static libray works. Is it nmake ms\ntall.mak test?
Frank

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial