Link dll against static build of QuaZip using Qt5.12 in VS2017

382 views Asked by At

I'm trying to link a .dll against a static builld of QuaZip library to get rid of the quazip.dll dependency at runtine. Since I've ran into a dependency conflict at production because a customer is using other third party applications in the same process where my .dll is uncluded, which are also using the quazip.dll but a legacy version. My steps were first to statically compile the zlib dependency as instructed in other posts with the ZLIB_WINAPI flag. Then I compiled QuaZip also with the appropriate ZLIB_WINAPI flag and QUAZIP_STATIC. As zlib.h I have used QtZlib/zlib.h header like in this post recommended. In my .dll project I've also tried to set all the mentioned flags (QUAZIP_STATIC seems to be necessary). Now when I try to compile my .dll I get the following errors

1>quazip.lib(zip.obj) : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol "__imp__z_deflate@8" in Funktion "_zipCloseFileInZipRaw64@16".
1>quazip.lib(zip.obj) : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol "__imp__z_deflateEnd@4" in Funktion "_zipCloseFileInZipRaw64@16".
1>quazip.lib(zip.obj) : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol "__imp__z_crc32@12" in Funktion "_zipWriteInFileInZip@12".
1>quazip.lib(unzip.obj) : error LNK2001: Nicht aufgelöstes externes Symbol "__imp__z_crc32@12".
1>quazip.lib(zip.obj) : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol "_imp__z_deflateInit2@32" in Funktion "_zipOpenNewFileInZip4_64@76".
1>quazip.lib(zip.obj) : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol "__imp__z_get_crc_table@0" in Funktion "_zipOpenNewFileInZip4_64@76".
1>quazip.lib(unzip.obj) : error LNK2001: Nicht aufgelöstes externes Symbol "__imp__z_get_crc_table@0".
1>quazip.lib(unzip.obj) : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol "__imp__z_inflate@8" in Funktion "_unzReadCurrentFile@12".
1>quazip.lib(unzip.obj) : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol "__imp__z_inflateEnd@4" in Funktion "_unzCloseCurrentFile@4".
1>quazip.lib(unzip.obj) : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol "_imp__z_inflateInit2@16" in Funktion "_unzOpenCurrentFile3@20".

All projects have been build with the /MT flag.

This is my linker command line

/OUT:"builds\qt5\dll\release\.dll" /MANIFEST /NXCOMPAT /PDB:"builds\qt5\dll\release\.pdb" /DYNAMICBASE "qtmain.lib" "Qt5Core.lib" "Qt5Gui.lib" "Qt5Widgets.lib" "Qt5Sql.lib" "Qt5Network.lib" "Qt5PrintSupport.lib" "qwt.lib" "sloperatecppapi.lib" "slgfw.lib" "slgfwwidget.lib" "slcap.lib" "sltrc.lib" "sltrp.lib" "slhmiutilitieslib.lib" "slaesvcadapter.lib" "slfsfilesvcadapter.lib" "sltraceadapter.lib" "slarchiveadapter.lib" "slmd.lib" "slgfwmanager.lib" "slcncversioninfo.lib" "quazip.lib" "setupapi.lib" "wsock32.lib" "ws2_32.lib" "ucrt.lib" "vcruntime.lib" "msvcrt.lib" "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib" /DLL /MACHINE:X86 /SAFESEH /INCREMENTAL:NO /PGD:"builds\qt5\dll\release<myapplication>.pgd" /SUBSYSTEM:WINDOWS /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /ManifestFile:"builds\qt5\dll\release<myapplication>.dll.intermediate.manifest" /ERRORREPORT:PROMPT /NOLOGO /LIBPATH:"S:\hmisl\lib" /LIBPATH:"S:\hmisl\siemens\sinumerik\hmi\osal\ace\lib" /LIBPATH:"S:\hmisl\siemens\sinumerik\hmi\osal\qt\lib" /LIBPATH:".\include\qt5\qwt\lib" /LIBPATH:".\include\qt5\quazip\lib" /LIBPATH:".\include\qt5\modbus\lib" /LIBPATH:".\include\qt5\qtsingleapplication\lib\release" /TLBID:1

I would be grateful for any new tip, because I've been trying this for almost a week now and I'm running out of ideas.

1

There are 1 answers

0
odd On BEST ANSWER

Ok, three days of agony and I have the solution. I recompiled the zlib, this time not using the provided project file in \contrib\vstudio\vc14, but generating my own with CMake. Then QuaZip linked against it with the flag QUAZIP_STATIC. I then set this flag in my project, which uses QuaZip and linked it against the built quazip.lib and its dependency zlibstatic.lib. Now the library is built into my .dll statically and I no longer have to supply the quazip.dll that caused the conflict.