zoukankan      html  css  js  c++  java
  • windows 下编译libcurl

    因为linux平台采用了libcurl,有一个程序移植到到windows平台,再linux采用libcurl。在windows下准备也采用该库。在网上搜索了几位同行写的,步骤上面有缺失。

    本文将以详细的步骤,介绍libcurl的编译。

    下面是步骤:

    1. 下载源代码,直接从github上clone仓库,就可以了。

         git clone https://github.com/curl/curl.git

    2. 选择版本

        我采用了版本: 7.56.0 (tag)

    3.  生成工程

        执行curl/projects文件下generate.bat,生成一个windows文件,文件夹下面有VS的工程,我选择的VS14。

        

      4.   打开curl-all.sln工程

      

    5.  选择编译的项目:

       

    6. 我们不需要OpenSSL 和 SSH2 两个库,我选择LIB Release执行,执行成功了。

        

    7. 编译支持ssl的库,再projects中有一个ReadMe.txt,我们打开看一下。

    The projects files also support build configurations that require third party dependencies such as OpenSSL, wolfSSL and SSH2. If you wish to support these, you will also need to download and compile those libraries as well.

    如果需要支持他们,需要download这些特性呢,需要安装并且编译这些库。文件的目录结构如下:

    8.  我们接下来去github下载openssl 和 ssh2吧。注意,目录结构要和curl在同一个文件夹下面。(github的服务器在老外,估计有时候下载速度有点慢,如果碰到了很慢的情况,耐心等待一会。喝茶中....)

           git clone https://github.com/openssl/openssl.git

                  git clone https://github.com/libssh2/libssh2.git

           9.   clone 完成,openssl 我采用了1.0.2 的版本, ssh2采用了1.9.0的版本

          10.  执行curl/projects/build-openssl.bat的批处理脚本

                Usage: build-openssl <compiler> <platform> [configuration] [directory]

                build-openssl vc14 x64 release  ../../openssl

                

         11. 选择编译选项的类型

         12. 执行结果查看,成功了。

             

      13. 在VS中引用生成的库。

            #include <curl/curl.h>

           #pragma comment(lib, "libcurl.lib")

          

            直接引用,会报error LNK2019: 无法解析的外部符号 __imp__curl_easy_init,该符号在函数 _main 中被引用 这个错误。

            需要定义下面的两个宏:

        然后开始编译,不再报错。

           

        

  • 相关阅读:
    倒计时功能的实现
    getElementsByClassName
    模拟滚动条
    display:table-cell
    gulp相关知识(2)
    gulp相关知识(1)
    移动端的网页试做
    关于移动端的布局
    伪类before和after
    简单时钟——css3
  • 原文地址:https://www.cnblogs.com/damizhou/p/11744096.html
Copyright © 2011-2022 走看看