用VistualStudio編譯OpenSSL

2019-07-08 又一次更新
這次是為了升級到可以支持TLS1.3,所以又要編譯OpenSSL,再次記錄一下。

  • 不能再用VS2005編譯了,我怎么試驗也不行。手頭現(xiàn)成的VS是2012所以就以它為示例
  • 首先就是要安裝ActivePerl
  • 啟動 Developer Command Prompt For VS2012
  • 然后運行如下命令
    > perl Configure VC-WIN32 #生成Makefile
    > nmake #直接編譯,以前會調(diào)用ms\do_ms之類的,新的OpenSSL中沒有這東西了
    

這樣就OK了

這之后在把編譯好的庫放入原來的工程中編譯的時候又出問題了,主要是編譯選項的Runtime Library:MDD MTD MD MT這個有沖突。那么這種沖突如何解決呢?以MD改MT為例

  • 找到目錄下生成的Makefile
  • 搜索MD (CFLAGS中的),找到后改成MT
  • 重新 nmake

就可以了


下面那一大堆都是自己以前的記錄,但是前幾天在翻看OpenSSL的源代碼的時候突然想調(diào)試一下,所以就想著怎么用編出給VS調(diào)試用的OpenSSL Library。雖然后來沒有實現(xiàn)自己的想法,不過找到一個不錯的網(wǎng)站,上面有已經(jīng)編譯好的OpenSSL的Library還有編譯方法。相比我的記錄就更加全面了,所以記錄一下。

Building OpenSSL with Visual Studio


@1

  1. Uncompress the openssl-1.0.1c.tar.gz, For example at C:\openssl-1.0.1c
  2. Install the ActivePerl
  3. Use the VS2005 Command Prompt
    Start->All Programs->Microsoft Vistual Studio 2005->Visual Studio Tools->Visual Studio 2005 Command Prompt
> perl configure VC-WIN32
> ms\do_ms

If you want to build the dlls, input:

> nmake -f ms\ntdll.mak

if you want to build the libs, input:

> nmake -f ms\nt.mak
  1. when the compiling is finished, you can find the dll&exe in <openssl-1.0.1c/out32dll> folder or you can find the lib&exe in <openssl-1.0.1c/out32> folder.
  2. If you want use openssl api in you project, please include the <openssl-1.0.1c/inc32> folder in you project.

@2

OpenSSL 1.0.1k compile error

I try to buld openssl-1.0.1k with Visual Studio...

> PERL Configure VC-WIN32... 
> ms\do_nasm 
> NMAKE -f ms\nt.mak 

and have one error:

.\crypto\cversion.c(80) : error C2065: 'cflags' : undeclared identifier

Simple patch:

diff U3 a/openssl-1.0.1k/crypto/cversion.c b/openssl-1.0.1k/crypto/cversion.c 
--- a/openssl-1.0.1k/crypto/cversion.c  Thu Jan 08 08:00:56 2015 
+++ b/openssl-1.0.1k/crypto/cversion.c  Thu Jan 08 10:16:03 2015 
@@ -77,7 +77,7 @@ 
    if (t == SSLEAY_CFLAGS) 
     { 
 #ifdef CFLAGS 
-    return(cflags); 
+    return(CFLAGS); 
 #else 
     return("compiler: information not available"); 
 #endif 

@3

OpenSSL 1.0.2e compile error

Building 1.0.2e has error

Assembling: tmp32\sha1-586.asm
tmp32\sha1-586.asm(1432) : error A2070:invalid instruction operands
tmp32\sha1-586.asm(1576) : error A2070:invalid instruction operands
NMAKE : fatal error U1077: "C:\Program Files (x86)\Microsoft Visual Studio 10.
0\VC\BIN\ml.EXE": return code "0x1"

The all asm SHOULD use NASM to build, so use NASM to replace the MS:

  1. Install the NASM, download from http://www.nasm.us/
  2. Add the NASM path to the $PATH

Build the OpenSSL:

> perl configure VC-WIN32
> ms\do_nasm
> nmake -f ms\nt.mak
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • **2014真題Directions:Read the following text. Choose the be...
    又是夜半驚坐起閱讀 11,014評論 0 23
  • PLEASE READ THE FOLLOWING APPLE DEVELOPER PROGRAM LICENSE...
    念念不忘的閱讀 13,641評論 5 6
  • 明天就是七夕節(jié)了,不知道你是否有約。是否會受到心愛的人的禮物,心情怎樣,是期盼多一點還是失望多一點? 我是一個85...
    晴兒1985閱讀 662評論 3 2
  • 今天看到了保姆縱火案的最新報道,有些話如鯁在喉,不吐不快。 根據(jù)相關(guān)調(diào)查,以及公安廳公布的材料,縱火者是保姆確認(rèn)無...
    黑頁飲馬槽閱讀 966評論 0 0
  • 天鴿過后網(wǎng)絡(luò)熱傳多篇類似《看到臺風(fēng)中扶車被壓身亡的男人,覺得人間真的好苦啊》的文字??吹阶詈螅艘痪渖?..
    最北的樹閱讀 420評論 1 3

友情鏈接更多精彩內(nèi)容