January 13, 2014

How to build OpenSSL in Win32

Post the content from http://softwerkz.net/2009/09/libtorrent/ Building OpenSSL Library This section is optional. However, if you wish to include OpenSSL library into your libtorrent, here are the steps to build it. Download ActivePerl and install it to assist the building of OpenSSL library. Download NASM and install it if you have not done so. Add the environment variable OPENSSL and set its value to the openssl folder e.g., D:\libtorrent\openssl-1.0.1c. Add the environment variable NASM and set its value to the nasm folder e.g., C:\Program Files (x86)\NASM. Execute the Visual Studio Command Prompt. (It can be found from Start Menu for Windows 7.) Then, run the following commands. perl Configure VC-WIN32 --prefix="%OPENSSL%" %NASM%\nasmpath.bat call ms\do_nasm nmake -f ms\nt.mak The OpenSSL libraries are located in folder, out32. =================error happened============================= Hi, I have gone through OpenSSL, but I can’t find libeay32lib and ssleay32.lib in $(OpenSSL)\out32. hm… weird. oh I just found an error after I ran nmake -f ms\nt.mak cl : Command line warning D9035 : option ‘O’ has been deprecated and will be rem oved in a future release o_str.c .\crypto\o_str.c(66) : fatal error C1083: Cannot open include file: ‘strings.h’: No such file or directory NMAKE : fatal error U1077: ‘”C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN \cl.EXE”‘ : return code ’0×2′ Stop. ========================How to solve ==================================== Hi Joon, Did you run “perl Configure VC-WIN32 –prefix=%OpenSSL%” with Visual Studio 2008 Command Prompt under the directory of your OpenSSL folder? Example (for my test case here): D:\openssl-1.0.0a>perl Configure VC-WIN32 –prefix=%OpenSSL% Your results will be something like the following:
Configuring for VC-WIN32 no-gmp [default] OPENSSL_NO_GMP (skip dir) no-jpake [experimental] OPENSSL_NO_JPAKE (skip dir) no-krb5 [krb5-flavor not specified] OPENSSL_NO_KRB5 no-md2 [default] OPENSSL_NO_MD2 (skip dir) no-rc5 [default] OPENSSL_NO_RC5 (skip dir) no-rfc3779 [default] OPENSSL_NO_RFC3779 (skip dir) no-shared [default] no-store [experimental] OPENSSL_NO_STORE (skip dir) no-zlib [default] no-zlib-dynamic [default] IsMK1MF=1 CC =cl CFLAG =-DOPENSSL_THREADS -DDSO_WIN32 -W3 -WX -Gs0 -GF -Gy -nologo -DOPENSSL_SYSNAME_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN ... < more of the definitions here > EX_LIBS = CPUID_OBJ =x86cpuid.o BN_ASM =bn-586.o co-586.o x86-mont.o DES_ENC =des-586.o crypt586.o AES_ENC =aes-586.o BF_ENC =bf-586.o CAST_ENC =cast-586.o RC4_ENC =rc4-586.o RC5_ENC =rc5-586.o MD5_OBJ_ASM =md5-586.o SHA1_OBJ_ASM =sha1-586.o sha256-586.o sha512-586.o RMD160_OBJ_ASM=rmd-586.o CMLL_ENC= =cmll-x86.o PROCESSOR = RANLIB =true ARFLAGS = PERL =perl THIRTY_TWO_BIT mode BN_LLONG mode RC4_INDEX mode RC4_CHUNK is undefined Configured for VC-WIN32.
If you look at the CFLAG values, you will find -DOPENSSL_SYSNAME_WIN32, this actually disable the #include in the o_str.c If look into the file o_str.c, you’ll see:
#if !defined(OPENSSL_IMPLEMENTS_strncasecmp) && \ !defined(OPENSSL_SYSNAME_WIN32) && \ !defined(NETWARE_CLIB) # include #endif
So two checks here. First make sure you are running the command under Visual Studio Command Prompt and the CFLAG has the mentioned flag. Also, you can open up the Configure file in the OpenSSL folder. Do a find on “OPENSSL_SYSNAME_WIN32″, you will see it in VC-WIN32 target. You can add it there or re-download the OpenSSL if it’s not there. Hope it helps.