libcurl 編譯指南(支援SSL)
阿新 • • 發佈:2019-02-02
首先,從libcurl官網下載原始碼:https://curl.haxx.se/download.html,我下載的是curl-7.48.0版本。其次,確認已經安裝了VS2008或者其他版本的Visual Studio。
由於之前使用VS編譯的libcurl庫不支援SSL,這次改用nmake來編譯。經過測試,nmake編譯出來的庫是支援SSL的。至於VS編譯出來的為什麼不行(配置了預處理也不行),暫時無從知曉。下面就介紹如何使用nmake來編譯出支援SSL的靜態庫:
開啟 Visual Studio 2008命令提示,cd 到 curl-7.48.0下的winbuild目錄,然後按照winbuild 目錄下BUILD.WINDOWS.txt檔案的說明,輸入:nmake
/f makefile.vc mode=static VC=9 ENABLE_IDN=no debug=no,然後回車開始編譯!值得注意一下:最好指定VC的版本號(VS2008的VC版本是9.0),否則外部程式編譯時,可能會出現“無法解析的外部符號”的提示錯誤。待編譯完成後,在 curl-7.48.0\builds\libcurl-vc7-x86-release-static-ipv6-sspi-winssl 目錄下,就是剛才編譯好的lib庫了。
====================================== 編譯選項 =========================================
Then you can call nmake /f Makefile.vc with the desired options (see below). The builds will be in the top src directory, builds\ directory, in a directory named using the options given to the nmake call. 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 versions WITH_DEVEL=<path> - Paths for the development files (SSL, zlib, etc.) Defaults to sibbling directory deps: ../deps Libraries 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 static WITH_CARES=<dll or static> - Enable c-ares support, DLL or static WITH_ZLIB=<dll or static> - Enable zlib support, DLL or static WITH_SSH2=<dll or static> - Enable libSSH2 support, DLL or static ENABLE_SSPI=<yes or no> - Enable SSPI support, defaults to yes ENABLE_IPV6=<yes or no> - Enable IPv6, defaults to yes ENABLE_IDN=<yes or no> - Enable use of Windows IDN APIs, defaults to yes Requires Windows Vista or later, or installation from: https://www.microsoft.com/downloads/details.aspx?FamilyID=AD6158D7-DDBA-416A-9109-07607425A815 ENABLE_WINSSL=<yes or no> - Enable native Windows SSL support, defaults to yes GEN_PDB=<yes or no> - Generate Program Database (debug symbols for release build) DEBUG=<yes or no> - Debug builds MACHINE=<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.