Please be sure to install the openssl-0.9.8a. openssl-1.0.0 I did not compile successfully.
How to compile OpenSSL under Windows (Vs2005 using Vc8 's CL compiler)
1, when installing activeperl//initialization, need to use the Perl interpreter
2. Use Visual Studio 2005 Command prompt under VS2005 to enter the console mode (this mode automatically sets various environment variables)
3. Unzip the OpenSSL package and enter the OpenSSL directory
4. Perl Configure Vc-win32
Try to execute the command in this directory, or you cannot find the Configure file, or specify the full configure file path.
5, Ms\do_ms
Execute the Ms\do_ms command in the Unzip directory
6, Nmake-f Ms\ntdll.mak
After compilation
Execute under the OpenSSL decompression directory and complete the compilation. Output files in Out32dll, including application executables, LIB files, and DLL files
Note: When you run step fifth, the CL compiler complains that the. \crypto\des\enc_read.c file is read as the POSIX name for this item is deprecated (not recommended) and is recommended for use with _read. Oh, I don't want to change all the read functions in OpenSSL to _read. Then look at CL error code C2220, so on MSDN find:
Warning treated as Error-no object file generated
/wx tells the compiler to treat all warnings as errors. Since An error occurred, no object or executable file is generated.
Because the/WX option is set, all warnings are treated as errors, so ...
So open the Ntdll.mak file under the MS directory in the OpenSSL directory, remove the Cflag/wx option and save it ...
Continue execution of Nmake-f Ms\ntdll.mak
So success ...
=================================
Go The process of compiling and using OpenSSL in VC6.0 posted on 2009-10-18 18:25 answer read (285) Comments (0) Edit favorite Category: C + +
First, compile and install OpenSSL
1. Follow the standard steps to install OpenSSL from source code
Perl needs to be properly installed prior to compiling OpenSSL because it is needed to compile OpenSSL.
Download the latest version of perl:http://downloads.activestate.com/activeperl/windows/. then install it.
Download the latest version of openssl:http://www.openssl.org/source/
The source is then decompressed into a directory (such as C:\openssl-0.9.8j).
Enter the OpenSSL source directory.
CD C:\OPENSSL-0.9.8.J
The following is a reference to the execution of file install.w32 under this directory:
Run Configure:
Perl Configure Vc-win32--prefix=c:/openssl
To create a makefile file:
Ms\do_ms
To compile a dynamic library:
Nmake-f Ms\ntdll.mak
To compile a static library:
Nmake-f Ms\nt.mak
To test the dynamic library:
Nmake-f Ms\ntdll.mak Test
To test a static library:
Nmake-f Ms\nt.mak Test
To install the dynamic library:
Nmake-f Ms\ntdll.mak Install
To install a static library:
Nmake-f Ms\nt.mak Install
Clear the compilation of the last dynamic library in order to recompile:
Nmake-f Ms\ntdll.mak Clean
Clears the compilation of the last Static library for recompilation:
Nmake-f Ms\nt.mak Clean
2, if it is too troublesome, do not want to compile, you can directly use others do a good job of Windows OpenSSL installation package (I use 0.9.8j version),
You can download OpenSSL for Windows from http://www.slproweb.com/products/Win32OpenSSL.html and install it directly.
P.S. OpenSSL for Windows Source code There are some data types that are incompatible with the compiler for VC6, and the incompatible data types I found are as follows:
In the Include/bn.h file under the OpenSSL installation directory,
#define Bn_ullong unsigned long long
#define Bn_ulong unsigned long long
#define Bn_long Long Long
To be modified separately as:
#define Bn_ullong Ulonglong
#define Bn_ulong Ulonglong
#define Bn_long Longlong
Otherwise, a compilation error occurs.
Ii. use of OpenSSL
Configure the use of the above function library in VC:
Click menu: Tools, Options, pop up the dialog "Options" and select the "Directories" tab in the dialog box.
Added "C:\openssl\include" to the "Include files" option in "Show Directories for:";
"Library Files" selected in the new directory "C:\openssl\lib".
Then add the following two sentences to the project that needs to link the OpenSSL function library:
#pragma comment (lib, "Ssleay32.lib")
#pragma comment (lib, "Libeay32.lib")
Its role is to import the libraries required by OpenSSL into the project.
Iii. issues
I encountered a problem similar to the following when I linked the static function library of OpenSSL:
Linking ...
MSVCRT.lib (MSVCRT.dll): Error LNK2005: _STRCHR already defined in LIBCMTD.lib (strchr.obj)
...
This is because the static function library of OpenSSL uses the release version of the VC's multithreaded DLL, and my program uses the release version of the multithreaded static link.
Adjust the version of the library function used by the static function library of OpenSSL and adjust the process as follows:
Edit the file Ms\nt.mak to the 19th line of the file
"Cflag=/md/ox/o2/ob2/w3/wx/gs0/gf/gy/nologo-dopenssl_sysname_win32-dwin32_lean_and_mean-dl_endian-ddso_win32 -d_crt_secure_no_deprecate-
D_CRT_NONSTDC_NO_DEPRECATE/FDOUT32-DOPENSSL_NO_CAMELLIA-DOPENSSL_NO_SEED-DOPENSSL_NO_RC5-DOPENSSL_NO_MDC2- DOPENSSL_NO_TLSEXT-DOPENSSL_NO_KRB5-
Dopenssl_no_dynamic_engine "
The "/MD" in is modified to "/MT". Then recompile and install OpenSSL.
Iv. Appendix: Instructions for compiling instructions for different versions of A/C + + Runtime library in VC
The compilation instructions for connecting different versions of the repository are described in detail in the article "description of different versions of the C + + runtime library in VC" (http://blog.yesky.com/271/dgkang/1737771.shtml):
C Runtime Library:
/MD MSVCRT. Release version of the LIB multithreaded DLL
/MDd MSVCRTD. Debug version of LIB multithreaded DLLs
/MT LIBCMT. LIB multi-threaded static link release version
/MTd LIBCMTD. LIB multi-threaded static link debug version
/clr MSVCMRT. LIB managed code and unmanaged code blending
/clr:pure Msvcurt. LIB Pure Managed code
C + + Standard Library:
/MD Msvcprt. Release version of the LIB multithreaded DLL
/MDd MSVCPRTD. Debug version of LIB multithreaded DLLs
/MT LIBCPMT. LIB multi-threaded static link release version
/MTd LIBCPMTD. LIB multi-threaded static link debug version
===============================================
A configuration compilation parameter
Configuring compilation parameters is the first step in OpenSSL compilation, which determines the environment of the system, what compiler to use, the default installation path, and some other options. The steps are as follows:
1. Install Perl: Download Activeperl-5.8.8.822-mswin32-x86-280952.msi, then click the MSI file to install!
Perl Learning Http://www.hongen.com/pc/program/tutors/perl/perl0001.htm
2. Configure compilation parameters: Download openssl-0.9.8g.tar.gz, unzip.
VC: First execute vcvars32.bat in the D:\Program Files\Microsoft Visual Studio. NET 2003\vc7\bin\ directory, and then in the extracted openssl-0.9.8g directory, Execute command Configuration compilation parameters: Perl Configure vc-win32
BC: Performed in the openssl-0.9.8g directory after decompression: Perl Configure BC-32
Two generation batch files
After you have configured the compilation parameters with the Configure script, you can use the batch command to generate the compilation script. Generating a compilation script typically uses different batch files depending on the compiler. For now, there are three options for compiling with VC: Do_ms,do_masm and Do_ NASM to create a series of compiled script files, namely. Mak scripts. The steps are as follows:
VC: In the openssl-0.9.8g directory, execute commands to batch files: Do_ms,do_masm and Do_nasm
bc:1. Download nsm09839.zip Microsoft Assembler compiler, unzip, copy to C:/windows directory, modify the name to Nasmw.exe;2. In the openssl-0.9.8g directory, execute the command to batch the file: Ms\do_nasm
Three-code compilation
Vc:
After completing the above steps, you can see two key script files: Nt.mak and Ntdll.mak. If we need a compiled OpenSSL library that supports dynamic DLLs, you should compile with the Ntddll.mak file. This completes the compilation we will get four files related to the OpenSSL API library: Ssleay32.lib,libeay32.lib,ssleay32.dll and Libeay32.dll. The form of the compiled command executed is as follows: Nmake-f ms\ Ntdll.mak
If you do not want to use OpenSSL in the form of a dynamic library, you can use the Nt.mak file to compile it. When using OpenSSL after compiling, the code is directly linked into our program. Execute the command as follows: Nmake-f Ms\nt.mak
BC: Execute command to complete code compilation: Make-f Ms\bcb.mak
Four ELSE
1
To test the dynamic library:
Nmake-f Ms\ntdll.mak Test
To test a static library:
Nmake-f Ms\nt.mak Test
To install the dynamic library:
Nmake-f Ms\ntdll.mak Install
To install a static library:
Nmake-f Ms\nt.mak Install
Clear the compilation of the last dynamic library in order to recompile:
Nmake-f Ms\ntdll.mak Clean
Clears the compilation of the last Static library for recompilation:
Nmake-f Ms\nt.mak Clean
2
Using OpenSSL
Configure the use of the above function library in VC:
Click menu: Tools, Options, pop up the dialog "Options" and select the "Directories" tab in the dialog box.
Add the directory "C:\openssl\include" to the "Include files" option in "Show Directories for:" and "C:\openssl\lib" in the "Library files" selection.
Then add "Libeay32.lib" when compiling a project that requires a link to the OpenSSL function library.
http://lwglucky.blog.51cto.com/1228348/325483
To compile OpenSSL under Windows (VS2005 and VC6)