1. 程式人生 > >VC++ 編譯libcurl 支援SSL,GZIP(有指令碼)

VC++ 編譯libcurl 支援SSL,GZIP(有指令碼)

      由於網上下載的 libcurl 不支援 gzip,只好自己動手編譯,期間走了很多彎路,下面是最終成功的記錄。

      我所使用的環境 Visual Studio 2010 、 Windows 7 64 bit

下載檔案

libcurl

下載頁面 http://curl.haxx.se/download.html

      下載地址 http://curl.haxx.se/download/curl-7.26.0.zip

zlib

     下載頁面 http://sourceforge.net/projects/libpng/files/zlib/

     下載地址 http://sourceforge.net/projects/libpng/files/zlib/1.2.5/zlib125.zip/download

openssl

      下載頁面 http://www.openssl.org/source/

      下載地址 http://www.openssl.org/source/openssl-1.0.0c.tar.gz

編譯openssl還需下載ActivePerl

             官方下載 http://www.activestate.com/activeperl/downloads

    下載地址:http://downloads.activestate.com/ActivePerl/releases/5.16.0.1600/ActivePerl-5.16.0.1600-MSWin32-x86-295879.msi

        X64下載地址:http://downloads.activestate.com/ActivePerl/releases/5.16.0.1600/ActivePerl-5.16.0.1600-MSWin32-x64-295879.msi

解壓及安裝檔案

         ActivePerl安裝,雙擊直接下一步,預設設定到底。

        zlib openssl libcurl分別解壓,他們三個在同一級目錄。

        例如:D:UserDeweiTestCurlcurl-7.26.0、D:UserDeweiTestCurlopenssl-1.0.0c、D:UserDeweiTestCurlzlib-1.2.5

編譯過程

zlib編譯

  用vs2010開啟zlib-1.2.5/old/visualc6/zlib.dsw,選擇DLL_Release編譯,把編譯生成的zlib-1.2.5/old/visualc6/Win32_DLL_Release/ zlib1.lib 複製到curl-7.26.0/lib目錄下,重新命名為 zdll.lib (注意必須為此檔名) 。

openssl編譯

       開啟cmd,cd到openssl-1.0.0c目錄下;

      執行命令 perl Configure VC-WIN32

      再執行 msdo_ms.bat

      再執行 “C:Program Files (x86)Microsoft Visual Studio 10.0vcvars32.bat”

      執行命令 nmake -f ms/ntdll.mak

編譯curl-7.26.0

     在curl-7.26.0/lib目錄下新建release.bat,輸入以下內容

    call “C:/Program Files/Microsoft Visual Studio 10.0/VC/bin/vcvars32.bat”
    set CFG=release-dll-ssl-dll-zlib-dll
    set OPENSSL_PATH=../../openssl-1.0.0c
    set ZLIB_PATH=../../zlib-1.2.5
    nmake -f Makefile.vc10

    儲存,然後執行。

    等待一會兒,就可以到 curl-7.26.0librelease-dll-ssl-dll-zlib-dll 目錄下拷檔案 libcurl_imp.lib和libcurl.dll 啦!

參考資料:curl-7.26.0/docs/INSTALL

Usage: nmake /f makefile.vc6 CFG=<config> <target>

where <config> is one of:

release - release static library

release-ssl - release static library with ssl

release-zlib - release static library with zlib

release-ssl-zlib - release static library with ssl and zlib

release-ssl-ssh2-zlib - release static library with ssl, ssh2 and zlib

release-ssl-dll - release static library with dynamic ssl

release-zlib-dll - release static library with dynamic zlib

release-ssl-dll-zlib-dll - release static library with dynamic ssl and dynam

ic zlib

release-dll - release dynamic library

release-dll-ssl-dll - release dynamic library with dynamic ssl

release-dll-zlib-dll - release dynamic library with dynamic zlib

release-dll-ssl-dll-zlib-dll - release dynamic library with dynamic ssl and dyna

mic zlib

debug - debug static library

debug-ssl - debug static library with ssl

debug-zlib - debug static library with zlib

debug-ssl-zlib - debug static library with ssl and zlib

debug-ssl-ssh2-zlib - debug static library with ssl, ssh2 and zlib

debug-ssl-dll - debug static library with dynamic ssl

debug-zlib-dll - debug static library with dynamic zlib

debug-ssl-dll-zlib-dll - debug static library with dynamic ssl and dynamic

zlib

debug-dll - debug dynamic library

debug-dll-ssl-dll - debug dynamic library with dynamic ssl

debug-dll-zlib-dll - debug dynamic library with dynamic zlib1

debug-dll-ssl-dll-zlib-dll - debug dynamic library with dynamic ssl and dynami

c zlib