当前位置:网站首页>Zlib static library compilation

Zlib static library compilation

2022-06-26 08:28:00 Tonyfield

Use... In projects minizip and zlib Static library , zlib use 1.2.11 edition (https://github.com/madler/zlib/archive/v1.2.11.zip) compile .

The errors reported after importing are as follows .

1>minizip.lib(mz_crypt.obj) : error LNK2019:  Unresolved external symbols  _crc32, The sign is in the function  _mz_crypt_crc32_update  Cited in 
1>minizip.lib(mz_strm_zlib.obj) : error LNK2019:  Unresolved external symbols  _deflate, The sign is in the function  _mz_stream_zlib_deflate  Cited in 
1>minizip.lib(mz_strm_zlib.obj) : error LNK2019:  Unresolved external symbols  _deflateEnd, The sign is in the function  _mz_stream_zlib_close  Cited in 
1>minizip.lib(mz_strm_zlib.obj) : error LNK2019:  Unresolved external symbols  _inflate, The sign is in the function  _mz_stream_zlib_read  Cited in 
1>minizip.lib(mz_strm_zlib.obj) : error LNK2019:  Unresolved external symbols  _inflateEnd, The sign is in the function  _mz_stream_zlib_close  Cited in 
1>minizip.lib(mz_strm_zlib.obj) : error LNK2019:  Unresolved external symbols  _deflateInit2_, The sign is in the function  _mz_stream_zlib_open  Cited in 
1>minizip.lib(mz_strm_zlib.obj) : error LNK2019:  Unresolved external symbols  _inflateInit2_, The sign is in the function  _mz_stream_zlib_open  Cited in 

But it's compiled from the Internet zlib1.2.5 or 1.2.8 No problem . So I began to doubt ZEXPORT Definition .

zconf.h in ZEXPORT There is a comment on the definition :“use WINAPI, not __stdcall”.

     /* No need for _export, use ZLIB.DEF instead. */
     /* For complete Windows compatibility, use WINAPI, not __stdcall. */
#      define ZEXPORT WINAPI

But in minwindef.h in WINAPI Defined as __stdcall , Seemingly expected and MSV Different definitions .

#elif (_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED)
#define CALLBACK    __stdcall
#define WINAPI      __stdcall
#define WINAPIV     __cdecl
#define APIENTRY    WINAPI
#define APIPRIVATE  __stdcall
#define PASCAL      __stdcall

So it is defined as follows , Recompile the static library . After importing the project, the compilation succeeded .

#      ifdef ZLIB_INTERNAL
#	     define ZEXPORT WINAPIV
#      else
#	     define ZEXPORT WINAPI
#      endif

But this causes dynamic library compilation errors , So add another judgment condition ( _WINDLL)

#      if !defined _WINDLL && defined ZLIB_INTERNAL
#	     define ZEXPORT WINAPIV
#      else
#	     define ZEXPORT WINAPI
#      endif

period , There are also some small mistakes :

SAFESEH The image is not secure

resolvent :https://blog.csdn.net/zengraoli/article/details/11919307

1. Open the “ Property page ” Dialog box .

2. single click “ The linker ” Folder .

3. single click “ Command line ” Property page .

4. take  /SAFESEH:NO  type “ Additional options ” In the box , And then click “ application ”.

bld_ml64.bat Call failed

Tried Microsoft Macro Assembler 8.0 (MASM) Package (x86), It doesn't work

It needs to be copied contribute In the catalog masm64 To the parent directory

 

 

 

 

原网站

版权声明
本文为[Tonyfield]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202170557056460.html