配置openssl方法

因项目需要,配置OPENSSL库花了将近一上午再加下午1个半小时才配置成功。

1.下载OPENSSL       http://www.openssl.org/source/

2.解压到vs所在盘

3.安装ActivePerl   http://www.activestate.com/ActivePerl   在环境变量中配置PATH

4.下载nasm     http://www.mouseos.com/assembly/nasm01.html    在环境变量PATH中配置安装路径

5. 将name.exe和ndisasm.exe拷贝至D:\Microsoft Visual Studio 12.0\VC\bin

6.设置

  1. Open a Command Prompt window.

  2. Set the OpenSSL_HOME variable to the location of the OpenSSL installation:

    set OpenSSL_HOME=path_to_your_OpenSSL_installation
  3. Set the OpenSSL_CONF variable to the location of the configuration file in your OpenSSL installation:

    set OpenSSL_CONF=path_to_your_OpenSSL_installation\bin\openssl.cfg
  4. Set the path to include the OpenSSL installation:

set Path=%Path%;%OpenSSL_HOME%\bin

7.

1)、运行Configure。(这里必须使用vs tools中vs开发者命令提示符。win8等找不到vs命令提示符的请参考网址: https://msdn.microsoft.com/zh-cn/ms229859(VS.80).aspx,这里如果使用cmd环境,编译时候一定会出错。 )


>cd C:\openssl
>perl Configure VC-WIN32 --prefix=c:/Openssl     这里指定安装目录
2)、创建Makefile文件。
>ms\do_ms
推荐使用这种方式,另外两种方式 如果使用也必须保证本机有编译器才能使用。
:ms\do_masm (默认vc 自带的编译器;也也以自己下载安装)
:ms\do_nasm (需要自己下载)(本人使用这种)
3)、配置VC环境变量。
>cd C:\Program Files\Microsoft Visual Studio\VC98\Bin
>vcvars32.bat
4)、编译。
>cd C:\openssl
>nmake -f ms\ntdll.mak        (加-a)

编译请打开参考文档参考 (注:openssl目录下的有install.win32安装说明)
Visual C++
 ----------
 If you want to compile in the assembly language routines with Visual
 C++, then you will need already mentioned Netwide Assembler binary,
 nasmw.exe or nasm.exe, to be available on your %PATH%.
 Firstly you should run Configure with platform VC-WIN32:
 > perl Configure VC-WIN32 --prefix=c:\some\openssl\dir
 Where the prefix argument specifies where OpenSSL will be installed to.
 Next you need to build the Makefiles and optionally the assembly
 language files:
 - If you are using NASM then run:
   > ms\do_nasm
 - If you don't want to use the assembly language files at all then run:
   > perl Configure VC-WIN32 no-asm --prefix=c:/some/openssl/dir
   > ms\do_ms
 If you get errors about things not having numbers assigned then check the
 troubleshooting section: you probably won't be able to compile it as it
 stands.
 Then from the VC++ environment at a prompt do:
 > nmake -f ms\ntdll.mak
 If all is well it should compile and you will have some DLLs and
 executables in out32dll. If you want to try the tests then do:
 
 > nmake -f ms\ntdll.mak test
 To install OpenSSL to the specified location do:
 > nmake -f ms\ntdll.mak install
 Tweaks:
 There are various changes you can make to the Win32 compile
 environment. By default the library is not compiled with debugging
 symbols. If you use the platform debug-VC-WIN32 instead of VC-WIN32
 then debugging symbols will be compiled in.
 By default in 1.0.0 OpenSSL will compile builtin ENGINES into the
 separate shared librariesy. If you specify the "enable-static-engine"
 option on the command line to Configure the shared library build
 (ms\ntdll.mak) will compile the engines into libeay32.dll instead.
 The default Win32 environment is to leave out any Windows NT specific
 features.
 If you want to enable the NT specific features of OpenSSL (currently
 only the logging BIO) follow the instructions above but call the batch
 file do_nt.bat instead of do_ms.bat.
 You can also build a static version of the library using the Makefile
 ms\nt.mak

5、检查下是否成功,执行命令:“nmake -f ms\ntdll.mak test”。
6、运行“nmake -f ms\ntdll.mak install”,或“nmake -f ms\nt.mak install”安装编译后的
OpenSSL到指定目录。
7、查看安装结果C:\Openssl下包含了三个文件夹Bin、include、lib。bin下包括
openssl.exe(openssl指令程序)、ssleay32.dll(ssl协议动态库)、libeay32.dll(密码算法库)。
lib下包括libeay32.lib,ssleay32.lib。Include目录包括了OpenSSL开发设计的头文件。
8、为VC添加头文件和静态链接库路径。
在Include files中增加C:\Openssl\include目录;
在Libray files中增加C:\openssl\out32dll。
9、编写OpenSSL程序,可参考C:\openssl\demos
(1) 包含相应头文件
#include <openssl/ssl.h>
#include <openssl/err.h>
#include <openssl/bio.h>

(2) 添加静态链接库
#pragma comment(lib, "libeay32.lib" )
#pragma comment(lib, "ssleay32.lib")
或ProjectàSettingsàLinkàObject\library modules填写libeay32.lib ssleay32.lib。
(3) 将动态链接库ssleay32.dll, libeay32.dll复制到C:\WINDOWS\system32或Debug目录下,确保动
态链接库在正确的路径。


*******************安装中遇到的问题:*********************
strings.h打不开,
ECPKPARAMETERS_it 重定义等现象主要原因在于错误的使用了cmd环境。

找不到strings.h
ECPKPARAMETERS_it重定义

这类问题,我也被困扰了一下午,偶然发现了原因,借这个地方给大家说下,免得以后大家范同样的错误。
错误的原因很简单:所有教程都没有说明一开始就要用VS命令行工具,甚至有人还专门说用“运行-CMD”来误导人!!!
必须以开始就是用VS命令行工具进行配置,编译就不会有任何问题!

另外,如果之前你已经编译出错了,请先清除:
nmake -f ms\ntdll.mak clean
nmake -f ms\nt.mak clean

收到帖子的启发:http://bbs.csdn.net/topics/350144211

如果还有问题的话多使用Google和度娘搜索吧!

编译时出错主要是因为国人喜欢windows编译环境和cmd,而国外则大多使用unix和linux,以及Mac等
**********************************************************

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值