Monday, November 8, 2021

Case Study 14: zlib compilation

Case Study 13: zlib compilation

    Prelude

  1. module unsafe for SAFESEH image C++
  2. zlib.lib got issue.

  3. My Research on this error
  4. the cause behind this error message.

    This happens when you link an .obj or .lib that contains code created by an earlier version of the compiler. Which of course would be common if you downloaded a binary for opencv_ffmpeg instead of the source. You can turn the linker option off but then you'll still have a CRT version incompatibility that can byte. Rebuild the library from source. – Hans Passant May 15 at 13:01

    It can also be caused by, as the error states, modules for which the linker can't find safe exception handlers. Assembly language modules in particular - as discussed in other answers. There is some info about this here. – Nick Westgate Jul 5 '17 at 22:17

    Building tricks

  5. Do not use WINAPI_FAMILY_ONE_PARTITION if not defined #233
  6. This fixes a compile time warning "C4067: unexpected tokens following preprocessor directive - expected a newline" (on VS2013 with Windows 8.1 SDK) and is is a follow up for commit 89e335a..

  7. zlib 1.2.8 always uses Windows 8 - level API #49
  8. DanKonigsbach commented on Sep 4, 2014

    As @kreuzerkrieg pointed out, the problem is in the commit 5481269, specifically on line 30. The code is trying to define IOWIN32_USING_WINRT_API if and only if the target is a Metro app, by using the test:

    #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)

    However, that will be true for both desktop and Metro applications. To test for only Metro applications, and not desktop applications, the following will work:

    #if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
    I would like to submit this as a fix. I'm new to GitHub, so I'll need to learn the process first..

  9. How to compile zLib 1.2.8 (WINAPI / WAPI / STDCALL version)
  10. MY NOTE: one solution is from this note:

    This is not a full-blown article - just a quick HOWTO for people who require the latest version of zLib and want to use it from a language (like classic VB) that requires a standard WinAPI interface..

    By default, zLib uses C calling conventions (CDECL). Gilles Vollant has helpfully provided an STDCALL version of zLib in the past, but his site only provides version 1.2.5, which dates back to January 2012. zLib is currently on version 1.2.8.

    Gilles has contributed his WAPI fixes to the core zLib distribution so that anyone can compile it themselves. To do this, you will need to download:

  11. Using the Windows 8 SDK to compile for Windows 7
  12. (This question uses zlib as an example but isn't specific to it.)

    I'm trying to compile zlib on Windows using the MSVC project file it comes with. I'm using VS2012 with the Windows 8 SDK, but my build machine is Windows 7..

  13. "The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name:" with identical names
  14. Try to add _CRT_NONSTDC_NO_DEPRECATE and _CRT_SECURE_NO_WARNINGS in the preprocessor options (project properties). Worked here..

  15. When does #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) in dxvahd.h Microsoft header file become true
  16. Hi I am having 2 VC++ solutions "A" & "B" (VS2008) both are having the same codebase (with just few lines of code different). Using DXVAHD.h in both.

    dxvahd.h is a standard Microsoft header file. If we open this header file, we see there is a conditional if "#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)".

  17. winsdk-10/Include/10.0.10240.0/shared/winapifamily.h
  18. Module Name: winapifamily.h Abstract: Master include file for API family partitioning..

  19. 'LIBCMT' conflicts with use of other libs + unresolved external symbols
  20. I have a program using OpenGL 3.2(+libs) and FreeType2. Then an other program with Boost and OpenSSL. The OpenGL side was to make sure text could be rendered and the boost/openssl program is to do a secure login/game server..

  21. warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library
  22. I don't know what is the problem here .. anybody can help me the source code is Hello Triangle.

  23. Unresolved externals despite linking in zlib.lib
  24. I've been trying to compile an application which utilizes zlib compression in VC++ 2010. I get the

    error LNK2019: unresolved external symbol _inflateInit2_ referenced in function ... error message, which wouldn't be unusual if I didn't link the lib. I link the static release zlib library..

    In my case I amended

    Config -> Linker -> Input -> Additional Dependencies to read ucrt.lib;vcruntime.lib;msvcrt.lib;kernel32.lib
    This enabled libz to build under Windows 10 with VS2015
    Ensuring the build type was /MD

    Source Code and FAQs

  25. zlib source code on GitHub
  26. zlib source code on GitHub.

    zlib 1.2.11 is a general purpose data compression library. All the code is thread safe. The data format used by the zlib library is described by RFCs (Request for Comments) 1950 to 1952 in the files http://tools.ietf.org/html/rfc1950 (zlib format), rfc1951 (deflate format) and rfc1952 (gzip format).

    All functions of the compression library are documented in the file zlib.h (volunteer to write man pages welcome, contact zlib@gzip.org).

    A usage example of the library is given in the file test/example.c which also tests that the library is working correctly. Another example is given in the file test/minigzip.c. The compression library itself is composed of all source files in the root directory.

  27. madler/zlib: on GitHub
  28. read this length readme.

    To compile all files and run the test program, follow the instructions given at the top of Makefile.in. In short "./configure; make test", and if that goes well, "make install" should work for most flavors of Unix. For Windows, use one of the special makefiles in win32/ or contrib/vstudio/ .

    Notes for some targets: - For Windows DLL versions, please see win32/DLL_FAQ.txt

  29. zlib - Looking the Gift Code in the Mouth:: A Post on Dr. Dobbs
  30. Free software is like pizza - when it’s good, it’s very good. When it’s bad, it can still be pretty good. This article takes a look at zlib, the free data compression library written by Mark Adler and Jean-loup Gailly. Like the very finest pizza, zlib is exceptional.

    In this article I will first give a quick overview of what zlib is, and where it came from. I’ll then discuss the existing interface, and look at the wrapper class I created for my own use. Finally, I’ll talk about how I integrated zlib into a a command line test program and a general purpose file compression OCX. After reading this article you should feel comfortable using zlib for many, if not all, of your data compression needs..

    zlib’s interface is confined to just a few simple function calls. The entire state of a given compression or decompression session is encapsulated in a C structure of type z_stream, whose definition is shown in Figure 1.

    Using the library to compress or decompress a file or other data object consists of three main steps:

    1. Creating a z_stream object.
    2. Processing input and output, using the z_stream object to communicate with zlib.
    3. Destroying the z_stream object.

  31. zlib FAQ
  32. Where can I get a Windows DLL version? The zlib sources can be compiled without change to produce a DLL. See the file win32/DLL_FAQ.txt in the zlib distribution. Pointers to the precompiled DLL are found in the zlib web site at http://zlib.net/ ..

    Where's the zlib documentation (man pages, etc.)? It's in zlib.h . Examples of zlib usage are in the files test/example.c and test/minigzip.c, with more in examples/ .

  33. zlib technical details and manuals
  34. zlib Information

    1. zlib Frequently Asked Questions
    2. zlib Manual
    3. zlib Usage Example
    4. zlib Technical Details
    5. zlib-related specifications:

  35. Frequently Asked Questions about ZLIB1.DLL
  36. Frequently Asked Questions about ZLIB1.DLL.

  37. Anatomy of the zlib library (3): use the example zpipe.c
  38. Anatomy of the zlib library (3): use the example zpipe.c.

  39. zlib official site
  40. A Massively Spiffy Yet Delicately Unobtrusive Compression Library (Also Free, Not to Mention Unencumbered by Patents).

  41. zlib Usage Example
  42. We often get questions about how the deflate() and inflate() functions should be used. Users wonder when they should provide more input, when they should use more output, what to do with a Z_BUF_ERROR, how to make sure the process terminates properly, and so on. So for those who have read zlib.h (a few times), and would like further edification, below is an annotated example in C of simple routines to compress and decompress from an input file to an output file using deflate() and inflate() respectively. The annotations are interspersed between lines of the code. So please read between the lines. We hope this helps explain some of the intricacies of zlib..

    zlib for Next Generation

  43. zlib replacement with optimizations for "next generation" systems.
  44. zlib data compression library for the next generation systems Maintained by Hans Kristian Rosbach aka Dead2 (zlib-ng àt circlestorm dót org).

  45. miniz: Single C source file zlib-replacement library, originally from code.google.com/p/miniza>
  46. miniz: Single C source file zlib-replacement library, originally from code.google.com/p/miniz.

  47. miniz
  48. This is a paragraphSingle C source file Deflate/Inflate compression library with zlib-compatible API, ZIP archive reading/writing, PNG writing.

  49. Richard Geldreich's Blog
  50. miniz.c: Finally added zip64 support, other fixes/improvements incoming.

  51. Building on Windows
  52. What follows is how BibleTime can be built on Windows using the free version of Visual Studio Express 2012.

  53. libpng
  54. libpng is the official PNG reference library. It supports almost all PNG features, is extensible, and has been extensively tested for over 23 years. The home site for development versions (i.e., may be buggy or subject to change or include experimental features) is https://libpng.sourceforge.io/, and the place to go for questions about the library is the png-mng-implement mailing list.

    libpng is available as ANSI C (C89) source code and requires zlib 1.0.4 or later (1.2.5 or later recommended for performance and security reasons). The current public release, libpng 1.6.37, fixes the use-after-free security vulnerability noted below, as well as an ARM NEON memory leak in the palette-to-RGB(A) expansion code (png_do_expand_palette())..

  55. LIBPNG: PNG reference library LIBPNG: PNG reference library
  56. source code library for libpng.

    Manual List

    1. plain text format
    2. PDF format (version 1.4.0 [Jan 2010], courtesy of Alex Yau)

    Specific questions on ZLIB_WIN32 macro

  57. build in windows with zlib should add ZLIB_WINAPI in MakefileBuild.vc
  58. I'd also be interested as to the "why do we need ZLIB_WINAPI ?",, and what version of ZLIB this applies to? I have been building ZLIB as a dependency of CURL for several years and not yet hit on this need.

    /* If building or using zlib with the WINAPI/WINAPIV calling convention,
    * define ZLIB_WINAPI.
    * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI.
    */
    30 second googling appears to indicate that it changes the expectations on the caller (it turns on __stdcall) which makes me nervous, but no more than that..

  59. ZLIB for Windows expects ZLIB_WINAPI to be defined #293
  60. ZLIB for Windows expects ZLIB_WINAPI to be defined #293.

  61. Static ZLIB (1.2.8) linking on Visual Studio 2012
  62. I can't, for the love of God, to static link the ZLIB libs. I have been struggling for a couple hours now with no success. Well, I have followed this tutorial and successfuly compiled both zlibstat.lib and zlibwapi.lib for 32 bits. After setting up my project to use the ZLIB folder with the libraries (Linker > General > Additional Library Directories) and setting zlibwapi.lib (only) as an dependency (Linker > Input > Additional Dependencies) I got it to work, however, that was a dynamic link (I need to distribute my application with the ZLIB dll). I usually use dynamic linking on Debug and static on Release.

    I have tried looking for what the hell is the zlibstat.lib and whats it used for, if not for static linking, assuming the "stat" suffix.

    Are there any preprocessor to be added into my project, something like ZLIB_STATIC or something, to use static linking of ZLIB or should I have never removed the ZLIB_WINAPI from the zlibstat project, just like the above link told me to do? Is it impossible to static link ZLIB (then, whats zlibstat.lib for?)?

  63. Zlib linker error on vs2010
  64. I have a zlib linker error. Spent several hours to try and solve the problem but nothing so far. Zlib was built using vs2010, win32 release. My project is using the same..

    Solution Including the zlib.h in the file like this:

    #ifdef WIN32 # define ZLIB_WINAPI #endif #include "zlib.h"

  65. Unresolved externals despite linking in zlib.lib
  66. I've been trying to compile an application which utilizes zlib compression in VC++ 2010. I get the

    error LNK2019: unresolved external symbol _inflateInit2_ referenced in function
    ....

    ANSWER: If you are using the VS2010 solution provided in contrib/ be aware that it's bugged. The zlibstat project defines ZLIB_WINAPI which according to zlib FAQ is used to switch on the STDCALL convention. Just remove it from the project settings and recompile the lib.

  67. Zlibstat.lib link error, VS 2010, zlib 1.2.8
  68. I am trying to use zlibstat.lib generated by building solution in zlib-1.2.8\contrib\vstudio\vc10\zlibvc.sln It generated a zlibstat.lib but when I link it with another project I get the following errors:

    error LNK2001: unresolved external symbol _compress2
    error LNK2001: unresolved external symbol _uncompress
    error LNK2019: unresolved external symbol _compress2 referenced in function...
    error LNK2019: unresolved external symbol _crc32 referenced in function .....

    ANSWER: For anyone coming across this question: I have just solved this myself minutes ago and I personally think that this is a small error in the 1.2.8 sources. The 1.2.8 release contains a VS2010 project to build the zlibstat.lib and altough one would expect a static library file given the name, the macro ZLIB_WINAPI is defined which produces a dynamically linked lib file.

    So without further ado: To compile zlibstat.lib in VS2010: Simply go to the project's proprerties, go to C/C++->Preprocessor and remove the ZLIB_WINAPI macro from the Preprocessor Definitions

  69. Compiling and using zlib library and libPng library under Windows
  70. I won't say anything about the zlib library and libpng. Both Du Niang and Google can tell you. Here mainly records how to use vs2010 to compile and use these two libraries under windows.

  71. Frequently Asked Questions about ZLIB1.DLL
  72. This document describes the design, the rationale, and the usage of the official DLL build of zlib, named ZLIB1.DLL. If you have general questions about zlib, you should see the file "FAQ" found in the zlib distribution, or at the following location: http://www.gzip.org/zlib/zlib_faq.html.

  73. Compilation and use of Zlib libraries
  74. this is the right approach from a chinese guy.

    Compilation and use of Zlib libraries.

  75. vs2010下创建工程调用zlib库compress和uncompress的问题
  76. Due to a project, the zlib library is used under windows. The existing libraries are all release versions. If the project is debugged, it will cause a lot of symbol errors, so I have to recompile the zlib library myself..

    上面写错了。首先要在Zlib.h头文件添加上ZLIB_WINAPI的宏定义(只有在vs2010的win32项目时候奥); 然后再 项目->属性->链接器->输入->忽略特定的默认库,把libcmt.lib,加上就ok了。

  77. use zlib lib to compress or decompress file
  78. MY Best Choice:

    If you want to compress or decompress file when writing C++ code,you can choose zlib library,that's quite easy..

  79. Using the Windows 8 SDK to compile for Windows 7
  80. (This question uses zlib as an example but isn't specific to it.) I'm trying to compile zlib on Windows using the MSVC project file it comes with. I'm using VS2012 with the Windows 8 SDK, but my build machine is Windows 7..

  81. zlib
  82. zlib From Wikipedia, the free encyclopedia.

    Applications

  83. Creating a Self Extracting Executable
  84. A class that allows you to create self extracting executables for use in distribution or setup programs.

  85. zipstream, bzip2stream: iostream wrappers for the zlib and bzip2 libraries
  86. STL compliant, stream-to-stream, zlib and bzip2 wrapper with wide char support..

  87. geromueller/zstream-cpp
  88. cleaned version on github.

  89. Encryption and compression, native and managed
  90. DLL for native encryption and compression (using Crypto++). Includes RSA Key Generator in C#, and encryption and compression in ASP.NET (C#)..

  91. Articles by Davide Pizzolato (Articles: 9)
  92. Articles by Davide Pizzolato (Articles: 9).

  93. CxImage
  94. CxImage is a C++ class to load, save, display, transform BMP, JPEG, GIF, PNG, TIFF, MNG, ICO, PCX, TGA, WMF, WBMP, JBG, J2K images.

  95. Zip and Unzip in the MFC way
  96. A library to create, modify, and extract Zip archives..

  97. Easy Way to Read/Write Zip-Compatible Files Under MFC
  98. Create a WinZip-readable ZIP file in three lines of your MFC code.

  99. Zip bytes in memory and unzip file into bytes buffer
  100. An article on how to zip bytes in memory.

  101. C++ wrapper for Gilles Vollant's Unzip API
  102. Presents an extended yet simplified interface to querying, filtering and extracting multiple files from a zip archive.

  103. HexEdit - Window Binary File Editor
  104. Open-source hex editor with powerful binary templates.

  105. CPathSplit
  106. This is a paragraph.

  107. CMarkupArchive, an extension to CMarkup
  108. This class adds additional features to the XML parser CMarkup: file handling, namespaces, numerical helpers and new find methods.

No comments:

Post a Comment