• 在Windows上编译最新的CURL,含有zlib,openssl


    最近,从网上下载了一个curl库,使用时各种报错,都无法启动,于是干脆就直接自己编译了。

        1. 准备工作

          a. 下载zlib

              zlib可以使得HTTP请求支持gzip压缩,其地址如下:

             官网:http://zlib.net/

             下载地址:http://zlib.net/zlib-1.2.8.tar.gz

         b. 下载openssl

              opensll使用与支持SSL,例如HTTPS的请求。

             官网:http://www.openssl.org

              下载地址:http://www.openssl.org/source/openssl-1.0.1f.tar.gz

         c. 下载curl

              官网:http://curl.haxx.se

              下载地址:在http://curl.haxx.se/download.html选择你所想要的版本,我这儿选用最新的7.35.0版本 [http://curl.haxx.se/download/curl-7.35.0.tar.gz]

        d. 下载ActivePerl

              官网:http://www.activestate.com/activeperl/downloads

              请注意根据自己的系统版本【32,64】选择不同的安装包【链接失效时用迅雷可下载】

             下载地址: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

        编译方法:

          a. 安装activePerl

             直接双击安装,用默认设置就可以了。

          b. 解压所有的源码文件,全部放在一个目录下,比如我是房子c:curl目录下,目录结构如下:

         

          c. 编译zlib

              从开始菜单,选择Microsoft Visual Studio 2005 > Visual Studio Tools > Visual Studio 2005 Command Prompt,如下图:

         之后会弹出一个CMD窗口,切换到zlib的目录下C:curlzlibxxx,然后输入:

    [plain] view plain copy
     
     print?在CODE上查看代码片派生到我的代码片
    1. nmake -f win32/Makefile.msc OBJA="inffast.obj"  


      过了一会儿就编译成功。

       2. 编译openssl

         将当前目录切换到C:curlopenssl-1.0.1f,如何输入下面执行下面的命令:

         ps:请不要直接打开cmd用vs自带的命令行工具

    [plain] view plain copy
     
     print?在CODE上查看代码片派生到我的代码片
    1. ms32all.bat  

    然后就开始了漫长的编译,我这等了15分钟才编译好= =$



      3. 编译curllib

        将当前目录切换到curl的的目录下C:curlcurl-7.35.0lib,然后依次输入一下的命令:

    [plain] view plain copy
     
     print?在CODE上查看代码片派生到我的代码片
    1. set OPENSSL_PATH=....openssl-1.0.1f  
    2. set ZLIB_PATH=....zlib-1.2.8  
    3. nmake -f Makefile.vc8  CFG=release-dll-zlib-dll  


    注意 Makefile.vc6是VC6.0的版本,VC8是VC2005,VC9是VS2008,依次类推吧。

    CFG是配置编译结果选项,其具体内容如下:

    [plain] view plain copy
     
     print?在CODE上查看代码片派生到我的代码片
    1. Usage: nmake /f makefile.vc6 CFG=<config> <target>  
    2. where <config> is one of:  
    3. release                      - release static library  
    4. release-ssl                  - release static library with ssl  
    5. release-zlib                 - release static library with zlib  
    6. release-ssl-zlib             - release static library with ssl and zlib  
    7. release-ssl-ssh2-zlib        - release static library with ssl, ssh2 and zlib  
    8. release-ssl-dll              - release static library with dynamic ssl  
    9. release-zlib-dll             - release static library with dynamic zlib  
    10. release-ssl-dll-zlib-dll     - release static library with dynamic ssl and dynamic zlib  
    11. release-dll                  - release dynamic library  
    12. release-dll-ssl-dll          - release dynamic library with dynamic ssl  
    13. release-dll-zlib-dll         - release dynamic library with dynamic zlib  
    14. release-dll-ssl-dll-zlib-dll - release dynamic library with dynamic ssl and dynamic zlib  
    15. debug                        - debug static library  
    16. debug-ssl                    - debug static library with ssl  
    17. debug-zlib                   - debug static library with zlib  
    18. debug-ssl-zlib               - debug static library with ssl and zlib  
    19. debug-ssl-ssh2-zlib          - debug static library with ssl, ssh2 and zlib  
    20. debug-ssl-dll                - debug static library with dynamic ssl  
    21. debug-zlib-dll               - debug static library with dynamic zlib  
    22. debug-ssl-dll-zlib-dll       - debug static library with dynamic ssl and dynamic zlib  
    23. debug-dll                    - debug dynamic library  
    24. debug-dll-ssl-dll            - debug dynamic library with dynamic ssl  
    25. debug-dll-zlib-dll           - debug dynamic library with dynamic zlib1  
    26. debug-dll-ssl-dll-zlib-dll   - debug dynamic library with dynamic ssl and dynamic zlib  
    27. <target> can be left blank in which case all is assumed  
    28. Makefile.vc8(501) : fatal error U1050: please choose a valid configuration "rele  
    29. ase-dll-ssl-dll-zlib-dll "  
    30. Stop.  

    大家可以根据自己的需要编译不同的DLL和lib,我就选择编译了两个静态库:

    [plain] view plain copy
     
     print?在CODE上查看代码片派生到我的代码片
    1. nmake -f Makefile.vc8  CFG=release-ssl-zlib  
    2. nmake -f Makefile.vc8  CFG=debug-ssl-zlib  

    然后就是开始华丽丽的刷屏等待啦~~~

        过了几分钟之后,就编译好了,将C:curlcurl-7.35.0lib会有debug-ssl-zlib和release-ssl-zlib目录,拷贝到VS的工程目下,然后配置一下就可以使用了。

  • 相关阅读:
    性能测试必备知识(10)- Linux 是怎么管理内存的?
    stat 命令家族(4)- 详解 iostat
    stat 命令家族(3)- 详解 mpstat
    stat 命令家族(2)- 详解 pidstat
    性能分析(6)- 如何迅速分析出系统 CPU 的瓶颈在哪里
    性能分析(5)- 软中断导致 CPU 使用率过高的案例
    实体类转xml
    运气一直好,就不只是运气了——记中学七年
    (数据科学学习手札93)利用geopandas与PostGIS进行交互
    JVM系列之一:内存区域和内存溢出
  • 原文地址:https://www.cnblogs.com/cappuccino/p/5436921.html
Copyright © 2020-2023  润新知