Windows compilation Libcurl (Openssl+zlib) (compiled with VC)

Source: Internet
Author: User

    • Libcurl main function is to use different protocols to connect and communicate with different servers, if using HTTPS, the need for OpenSSL
    • Libcurl Download the source archives
    • ActiveState to download the Perl parser, compile OpenSSL needs to be used.
    • OpenSSL openssl-1.0.2k,1.1.0 after the file and installation methods are changed.
    • zlib a version other than 1.2.7, such as 1.2.11.

To facilitate installation, create a new folder named Libcurl-ssl in the D-Packing directory and extract the downloaded three compressed packages to the folder.
Create a new folder under curl-7.54.0-I OpenSSL is used to store the header file for OpenSSL.

Zlib Compile:
    1. Zlib-1.2.11\contrib\vstudio\vc14\zlibvc.sln, compile release version.
    2. There are Zlibwapi.dll and Zlibwapi.lib files in the generated X86\zlibdllrelease folder
ActiveState Installation:

Open the installation package, select Modify default installation or repair modify the installation path to

OpenSSL compilation:

This is the most troublesome and error-prone link because he has no project files and can only be compiled from the command line.

    1. Find the VS VS2015 x86 native tools command Prompt in the Start menu
    2. Use the CD command to go to the openssl-1.0.2k folder
    3. Command line type Perl Configure vc-win32 no-asm
    4. Command line type Ms\do_ms.bat
    5. Command line type Nmake-f Ms/ntdll.mak

Wait for almost five minutes, as long as the "stop" does not appear, safe execution to the end, even if successful.
Once there is a mistake in the middle, it is best to delete the folder, re-unzip, configure the compilation, if you leave the compilation of the failed semi-finished, it may tell you "Cannot parse xxx".

The Libeay32.lib, Libeay32.dll, Ssleay32.lib, Out32dll of openssl-1.0.2k, Inc32, and openssl-1.0.2k, Ssleay32.dll together to the curl-7.54.0, Lib, and OpenSSL

Libcurl Compile:

Compile platform selection DLL Debug-dll OpenSSL

    1. curl-7.54.0->projects, Windows---VC14, Curl-all.sln, you may be prompted to upgrade the project, OK.
    2. Set Libcurl as the Startup project, select Libcurl, Resource files, and libcurl.rc, right-click "Move Out", which records the version information, will only increase the file, you can move out.
    3. Select the preprocessor definition, C + + +, properties, and then change "Building_libcurl" to "Curl_staticlib". That way, those interface functions are not declared as export functions.
    4. Select Properties---linker---Add additional Library directories: \.. \.. \.. \lib\openssl, to Curl-7.54.0, Lib, and OpenSSL
    5. Select Properties, linker, input, and additional dependencies add libeay32.lib;ssleay32.lib;ws2_32.lib;wldap32.lib; The first two are for OpenSSL, and the latter two are for curl to depend on.

Libcurld.dll and Libcurld.lib are generated in the DLL debug-dll OpenSSL folder, curl-7.54.0, build, Win32, VC14, after compilation is successful (note The meaning of the name is not libcurl).

To create a console application

For example, the created project folder is located in D:-Libcurltest, and the compiled version is debug X86.

    1. Create a new libcurltest. Include folder, and copy the past with the Curl folder under the Include directory, curl-7.54.0.
    2. Create a new libcurltest. lib folder and create a new debug folder under Lib. Copy the Libcurl compiled Libcurld.dll and libcurld.lib to debug.
    3. Libcurld.dll and previous OpenSSL generated Libeay32.dll, ssleay32.dll each copy to the project folder, or will report an error.
    4. Select the preprocessor definition, c\c++, configuration Properties, and add Curl_staticlib.
    5. The additional Include directories, additional library directories, and additional dependencies in the properties are implemented in the code.
Test code
#include "stdafx.h"
#include "../include/curl/curl.h"     
#pragma comment(lib,"../lib/debug/libcurld.lib")    
int main()
    CURL *curl;
    CURLcode res;
    curl = curl_easy_init();
    if (curl)
        curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, false);
        curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, true);
        curl_easy_setopt(curl, CURLOPT_URL, "");
        curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
        res = curl_easy_perform(curl);
        if (res != CURLE_OK)
            fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res));
    return 0;

Running results: The Web page source is displayed in the console, and HTTPS cannot be accessed without the compile and link of OpenSSL. But the display Chinese part is garbled, I level limited, think this is C + + output problem, I will save the source to txt open is no problem.

Note: This document is organized and modified from the Internet.

Source: Pinterest
Copyright belongs to the author. Commercial reprint please contact the author for authorization, non-commercial reprint please specify the source.

Windows compilation Libcurl (Openssl+zlib) (compiled with VC)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.