代码改变世界

zlib编译安装

  youxin  阅读(3678)  评论(1编辑  收藏  举报

http://www.zlib.net/下载了最新的源代码

zlib提供了vs sln文件,在zlib-1.2.8\contrib\vstudio\目录有

其中的zlibstat是编译为静态库
zlibvc是编译为动态库,还有其它一些工程暂时未研究

 

windows上编译倒是会成功。

有一个项目调用zlib,发生错误

zconf.h Cannot open include file: 'unistd.h': No such file or directory

看了有些说明,说可以这么做:

If you're using ZLib in your project, then you need to find :

#if 1
in zconf.h and replace(uncomment) it with :

#if HAVE_UNISTD_H /* ...the rest of the line
If it isn't ZLib I guess you should find some alternative way to do this. GL.

参考:http://www.360doc.com/content/13/0124/17/1200324_262179628.shtml

 

vc 创建win32工程,在]win32下调用zlib库的函数compress编译错误(error LNK2019: 无法解析的外部符号 _compress?

答案:把zlib 1.2.5加入自己的项目,编译时有两点要注意
1.就是zlib 1.2.5源代码包中\contrib\vstudio\readme.txt中说的在使用zlib要预定义宏ZLIB_WINAPI,否则无法编译通过。
- To use zlibwapi.dll in your application, you must define the  macro ZLIB_WINAPI when compiling your application's source files.
2.链接时,除了#pragma comment(lib, "zlibvc.lib")添加引入库外,还要注意Character Set的设置要统一。否则也会出现链接错误,提示找不到_compress外部变量。 

我在工程属性->C++->预定义宏->预处理器定义 .增加ZLIB_WINAPI这个宏,然后link就好了就好了。

 http://blog.csdn.net/xiabodan/article/details/38391171?utm_source=tuicool&utm_medium=referral

http://blog.sina.com.cn/s/blog_96ea53fb0101ldd9.html

 

编辑推荐:
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· .NET Core 中如何实现缓存的预热?
· 三行代码完成国际化适配,妙~啊~
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
历史上的今天:
2012-12-22 windows dll使用
点击右上角即可分享
微信分享提示