在windows下,编译可访问https的libcurl静态库过程
1. 首先編譯openssl靜態庫
整個過程用的是 vs2015命令提示工具
需要安裝perl
下載地址:添加鏈接描述
解壓后, 在 openssl-1.0.2e目錄下創建develop這個文件夾, cd到 openssl-1.0.2e目錄下,
a.配置編譯文件和模式
執行
VC-WIN32標識windows 32位操作系統,
64位用VC-WIN64A表示, 若要使用debug版本,請使用debug-VC-WIN64A或debug-VC-WIN32
no-asm 表示不用匯編
–prefix=E:\curl\openssl-1.0.2e\develop 是設置安裝目錄
b.生成編譯配置文件
若為Windows 64位系統,執行
若為Windows 32位系統,執行
ms\do_ms.bat執行這一步之后,在ms目錄下會生成nt.mak和ntdll.mak兩個編譯配置文件
nt.mak 用于生成靜態lib庫
ntdll.mak 用于生成動態dll庫
c.編譯
靜態庫
動態庫
nmake -f ms\ntdll.makd.測試
測試靜態庫:
測試動態庫:
nmake -f ms\ntdll.mak test若最終顯示 passed all tests 則說明生成的庫正確
e.安裝
安裝靜態庫:
安裝動態庫:
nmake -f ms\ntdll.mak install編譯安裝完成后,會在E:\curl\openssl-1.0.2e\develop目錄下看到生成的相關文件夾
f.清楚上次編譯
清除上次靜態庫的編譯,以便重新編譯:
清除上次動態庫的編譯,以便重新編譯:
nmake -f ms\ntdll.mak clean參考:https://blog.csdn.net/mayue_web/article/details/83997969,非常詳細
2.編譯zlib
a.下載源碼
http://zlib.net/zlib-1.2.11.tar.gz
解壓后,在zlib根目錄下 命令行執行
nmake -f win32/Makefile.msc
3.編譯libcurl
a.下載源碼
http://curl.haxx.se/download/curl-7.46.0.tar.bz2
b.拷貝所需的openssl與zlib相關庫與頭文件
.根據curl源代碼根目錄下winbuild目錄下BUILD.WINDOWS.txt的提示
在源代碼同級的目錄下建立deps文件夾
此時的目錄結構如下圖(偽目錄)
我這里的deps文件夾目錄是 E:\curl\deps
將編譯openssl時候,安裝目錄E:\curl\openssl-1.0.2e\develop\include下的
openssl夾拷貝到E:\curl\deps\include\目錄下;
將zlib源碼根目錄下的zconf.h、zlib.h和zutil.h拷貝到E:\curl\deps\include目錄下。
將E:\curl\openssl-1.0.2e\develop\lib目錄下的libeay32.lib和ssleay.lib拷貝到E:\curl\deps\lib目錄下;
將zlib源碼根目錄下的zlib.lib拷貝到E:\curl\deps\lib目錄下。
c.編譯libcurl
命令行進入源代碼根目錄下 winbuild 目錄
參數詳細含義如下:
nmake /f Makefile.vc mode=<static or dll> <options>where <options> is one or many of:VC=<6,7,8,9,10,11,12,14> - VC versionsWITH_DEVEL=<path> - Paths for the development files (SSL, zlib, etc.)Defaults to sibbling directory deps: ../depsLibraries can be fetched at http://windows.php.net/downloads/php-sdk/deps/Uncompress them into the deps folder.WITH_SSL=<dll or static> - Enable OpenSSL support, DLL or staticWITH_CARES=<dll or static> - Enable c-ares support, DLL or staticWITH_ZLIB=<dll or static> - Enable zlib support, DLL or staticWITH_SSH2=<dll or static> - Enable libSSH2 support, DLL or staticENABLE_SSPI=<yes or no> - Enable SSPI support, defaults to yesENABLE_IPV6=<yes or no> - Enable IPv6, defaults to yesENABLE_IDN=<yes or no> - Enable use of Windows IDN APIs, defaults to yesRequires Windows Vista or later, or installation from:http://www.microsoft.com/downloads/details.aspx?FamilyID=AD6158D7-DDBA-416A-9109-07607425A815ENABLE_WINSSL=<yes or no> - Enable native Windows SSL support, defaults to yesGEN_PDB=<yes or no> - Generate Program Database (debug symbols for release build)DEBUG=<yes or no> - Debug buildsMACHINE=<x86 or x64> - Target architecture (default is x86)Static linking of Microsoft's C RunTime (CRT): ============================================== If you are using mode=static nmake will create and link to the static build of libcurl but *not* the static CRT. If you must you can force nmake to link in the static CRT by passing RTLIBCFG=static. Typically you shouldn't use that option, and nmake will default to the DLL CRT. RTLIBCFG is rarely used and therefore rarely tested. When passing RTLIBCFG for a configuration that was already built but not with that option, or if the option was specified differently, you must destroy the build directory containing the configuration so that nmake can build it from scratch.Legacy Windows and SSL ====================== When you build curl using the build files in this directory the default SSL backend will be WinSSL (Windows SSPI, more specifically Schannel), the native SSL library that comes with the Windows OS. WinSSL in Windows <= XP is not able to connect to servers that no longer support the legacy handshakes and algorithms used by those versions. If you will be using curl in one of those earlier versions of Windows you should choose another SSL backend like OpenSSL.3.驗證
vs2015
添加好包含目錄 ,附加庫目錄, 附加依賴項后,預處理器添加上BUILDING_LIBCURL
參考:
https://blog.csdn.net/fm0517/article/details/91822880
https://blog.csdn.net/huangyimo/article/details/80337496
總結
以上是生活随笔為你收集整理的在windows下,编译可访问https的libcurl静态库过程的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 刺客终结追击怎么用?
- 下一篇: 成都大熊猫繁育研究基地周一是否闭馆