zlib編譯安裝


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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM