配置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.0VCin
6.设置
-
Open a Command Prompt window.
-
Set the
OpenSSL_HOME
variable to the location of the OpenSSL installation:set OpenSSL_HOME=
path_to_your_OpenSSL_installation
-
Set the
OpenSSL_CONF
variable to the location of the configuration file in your OpenSSL installation:set OpenSSL_CONF=
path_to_your_OpenSSL_installation
inopenssl.cfg -
Set the path to include the OpenSSL installation:
set Path=%Path%;%OpenSSL_HOME%in
7.
1)、运行Configure。(这里必须使用vs tools中vs开发者命令提示符。win8等找不到vs命令提示符的请参考网址:https://msdn.microsoft.com/zh-cn/ms229859(VS.80).aspx,这里如果使用cmd环境,编译时候一定会出错。)编译请打开参考文档参考:(注: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:someopenssldir 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: > msdo_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 > msdo_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 tdll.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 tdll.mak test To install OpenSSL to the specified location do: > nmake -f ms tdll.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 tdll.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 t.mak
5、检查下是否成功,执行命令:“nmake -f ms tdll.mak test”。 6、运行“nmake -f ms tdll.mak install”,或“nmake -f ms t.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:Opensslinclude目录; 在Libray files中增加C:opensslout32dll。 9、编写OpenSSL程序,可参考C:openssldemos (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àObjectlibrary modules填写libeay32.lib ssleay32.lib。 (3) 将动态链接库ssleay32.dll, libeay32.dll复制到C:WINDOWSsystem32或Debug目录下,确保动 态链接库在正确的路径。
*******************安装中遇到的问题:*********************
strings.h打不开, ECPKPARAMETERS_it重定义等现象主要原因在于错误的使用了cmd环境。
找不到strings.h
ECPKPARAMETERS_it重定义
这类问题,我也被困扰了一下午,偶然发现了原因,借这个地方给大家说下,免得以后大家范同样的错误。
错误的原因很简单:所有教程都没有说明一开始就要用VS命令行工具,甚至有人还专门说用“运行-CMD”来误导人!!!
必须以开始就是用VS命令行工具进行配置,编译就不会有任何问题!
另外,如果之前你已经编译出错了,请先清除:
nmake -f ms tdll.mak clean
nmake -f ms t.mak clean
收到帖子的启发:http://bbs.csdn.net/topics/350144211
如果还有问题的话多使用Google和度娘搜索吧!
编译时出错主要是因为国人喜欢windows编译环境和cmd,而国外则大多使用unix和linux,以及Mac等 **********************************************************
声明:该文观点仅代表作者本人,入门客AI创业平台信息发布平台仅提供信息存储空间服务,如有疑问请联系rumenke@qq.com。
- 上一篇:没有了
- 下一篇:没有了