Source code package: libpng-1.2.8, zlib-1.2.5
Compilation tool: vs2008
1. Compile zlib-1.2.5
1.1 error message: match686.obj and inffas32.obj cannot be found.
Solution: Check the attached dependency items.
... \ Masmx86 \ match686.obj
.. \ Masmx86 \ inffas32.obj
Find the two files match686.asm and inffas32.asm in the corresponding directory. After reading the instructions in these two files, you can compile them:
Open the Visual Studio 2008 command prompt in the Start Menu, go to the masmx86 directory, and execute
ML/COFF/Zi/C/flinffas32.lst inffas32.asm
Generate the inffas32.obj File
ML/COFF/Zi/C/flmatch686.lst match686.asm
Generate the match686.obj File
1.2 The following error occurs: the fatal error c1853 precompiled header file comes from an earlier version of the compiler, or the precompiled header is C ++ and is used in C (or vice versa) or
An unexpected file ending occurs when you look for the pre-compiled header. Forgot to add # include "stdafx. H to the source?
Solution: Find all. C source files and right-click Properties. The pre-compilation header will be removed without the pre-compilation header.
1.3 Test the generated lib file and dll library.
This function is used to generate an export function using the def definition file, but the zlib. h header file is used for reference. You need to import the function.
There is a zexport macro definition in the header file of zlib. H, and a Conditional compilation macro zlib_winapi, which must be compiled with the preceding conditions in the project preprocessing attribute. In the same project, there is a testzlib project that contains all the required Conditional compilation variables and can be copied directly. Specifically:
Asmv
Asminf
Win32
_ Debug
_ Console
Zlib_winapi
_ Crt_nonstdc_no_deprecate
_ Crt_secure_no_deprecate
_ Crt_nonstdc_no_warnings
2. Introduce the zlib library into the tool, add the zlib header file, and start to compile the libpng-1.2.8
21. The following error occurs:
1> PNG. OBJ: Error lnk2019: unresolved external symbol _ imp _ CRC32 referenced in function _ png_reset_crc
1> PNG. OBJ: Error lnk2019: unresolved external symbol _ imp _ inflatereset referenced in function _ png_reset_zstream
1> pngpread. OBJ: Error lnk2001: unresolved external symbol _ imp _ inflatereset
1> pngrutil. OBJ: Error lnk2001: unresolved external symbol _ imp _ inflatereset
1> pngpread. OBJ: Error lnk2019: unresolved external symbol _ imp _ inflate referenced in function _ png_process_idat_data
1> pngread. OBJ: Error lnk2001: unresolved external symbol _ imp _ inflate
1> pngrutil. OBJ: Error lnk2001: unresolved external symbol _ imp _ inflate
1> pngread. OBJ: Error lnk2019: unresolved external symbol _ imp _ inflateinit _ referenced in function _ png_create_read_struct_2
1> pngread. OBJ: Error lnk2019: unresolved external symbol _ imp _ inflateend referenced in function _ png_read_destroy
1> pngwrite. OBJ: Error lnk2019: unresolved external symbol _ imp _ deflate referenced in function _ png_write_flush
1> pngwutil. OBJ: Error lnk2001: unresolved external symbol _ imp _ deflate
1> pngwrite. OBJ: Error lnk2019: unresolved external symbol _ imp _ deflateend referenced in function _ png_write_destroy
1> pngwutil. OBJ: Error lnk2019: unresolved external symbol _ imp _ deflateinit2 _ referenced in function _ png_write_ihdr
1> pngwutil. OBJ: Error lnk2019: unresolved external symbol _ imp _ deflatereset referenced in function _ png_write_compressed_data_out
Solution: Let's take a closer look at the corresponding zlib library methods, which are actually defined. It is not an external symbol that cannot be included. There is only a Conditional compilation switch. Add the following content to the Preprocessor as described in section 1.3:
Asmv
Asminf
Win32
_ Debug
_ Console
Zlib_winapi
_ Crt_nonstdc_no_deprecate
_ Crt_secure_no_deprecate
_ Crt_nonstdc_no_warnings
In addition, note: during compilation, the CPU type must be consistent, or both are Win32. inconsistency may also cause the above errors.
Compilation is passed.