windows下libcurl与zlib和ssl共同编译

下载了curl 7.37,在project里有各个版本VS对应的项目文件,我们选择合适的打开即可以编译,根据不同的项目配置输出想要的库,比如可以切换多种SSL库,dll/lib,debug/release等。

但是这些项目配置中没有zlib,很不方便。而官网的INSTALL文档http://curl.haxx.se/docs/install.html,也是简单的说明了如何使用MSVC命令行编译libcurl和zlib,或者libcurl和openssl,原文如下:

   If you want to compile with zlib support, you will need to build
   zlib (http://www.gzip.org/zlib/) as well. Please read the zlib
   documentation on how to compile zlib. Define the ZLIB_PATH environment
   variable to the location of zlib.h and zlib.lib, for example:
 
     set ZLIB_PATH=c:zlib-1.2.8
 
   Then run 'nmake vc-zlib' in curl's root directory.

那我需要windows下的libcurl同时有zlib和SSL的支持呢?方法是有的,请查看winbuild/BUILD.WINDOWS.txt,里面讲述了详细的编译选项。最后总结一下步骤吧:
1.编译zlib,将头文件和生成的库文件分别放入 D:/deps/include和D:/deps/lib
2.cd curl-srcwinbuild
3.nmake /f Makefile.vc mode=dll WITH_DEVEL=D:/deps WITH_ZLIB=dll ENABLE_WINSSL=yes DEBUG=no


注意如果项目需要使用静态的Liburl库时,需要在编译项目时加上宏 CURL_STATICLIB,否则会在链接的过程中报错

原文地址:https://www.cnblogs.com/guoxiaoqian/p/4328839.html