[Solved] Cannot get QuaZip (test) to work



  • Hallo,

    For the last 3 hours I've been trying to get QuaZip (0.4.1 with zlib 1.2.5) to work, but so far no success. It builds fine in both Debug and Release Mode, but any test I try will abort with linker errors like this one:

    @
    1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall QuaZip::close(void)" (_imp?close@QuaZip@@QAEXXZ) referenced in function "bool __cdecl testCreate(void)" (?testCreate@@YA_NXZ)
    1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual void __thiscall QuaZipFile::close(void)" (_imp?close@QuaZipFile@@UAEXXZ) referenced in function "bool __cdecl testCreate(void)" (?testCreate@@YA_NXZ)
    1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: int __thiscall QuaZipFile::getZipError(void)const " (_imp?getZipError@QuaZipFile@@QBEHXZ) referenced in function "bool __cdecl testCreate(void)" (?testCreate@@YA_NXZ)
    1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall QuaZipNewInfo::~QuaZipNewInfo(void)" (_imp??1QuaZipNewInfo@@QAE@XZ) referenced in function "bool __cdecl testCreate(void)" (?testCreate@@YA_NXZ)
    1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: bool __thiscall QuaZipFile::open(class QFlags<enum QIODevice::OpenModeFlag>,struct QuaZipNewInfo const &,char const *,unsigned int,int,int,bool,int,int,int)" (_imp?open@QuaZipFile@@QAE_NV?$QFlags@W4OpenModeFlag@QIODevice@@@@ABUQuaZipNewInfo@@PBDIHH_NHHH@Z) referenced in function "bool __cdecl testCreate(void)" (?testCreate@@YA_NXZ)
    1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall QuaZipNewInfo::QuaZipNewInfo(class QString const &,class QString const &)" (_imp??0QuaZipNewInfo@@QAE@ABVQString@@0@Z) referenced in function "bool __cdecl testCreate(void)" (?testCreate@@YA_NXZ)
    1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall QuaZipFile::~QuaZipFile(void)" (_imp??1QuaZipFile@@UAE@XZ) referenced in function "bool __cdecl testCreate(void)" (?testCreate@@YA_NXZ)
    1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall QuaZipFile::QuaZipFile(class QuaZip *,class QObject *)" (_imp??0QuaZipFile@@QAE@PAVQuaZip@@PAVQObject@@@Z) referenced in function "bool __cdecl testCreate(void)" (?testCreate@@YA_NXZ)
    1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall QuaZip::setComment(class QString const &)" (_imp?setComment@QuaZip@@QAEXABVQString@@@Z) referenced in function "bool __cdecl testCreate(void)" (?testCreate@@YA_NXZ)
    1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall QuaZip::~QuaZip(void)" (_imp??1QuaZip@@QAE@XZ) referenced in function "bool __cdecl testCreate(void)" (?testCreate@@YA_NXZ)
    1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: int __thiscall QuaZip::getZipError(void)const " (_imp?getZipError@QuaZip@@QBEHXZ) referenced in function "bool __cdecl testCreate(void)" (?testCreate@@YA_NXZ)
    1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: bool __thiscall QuaZip::open(enum QuaZip::Mode,struct zlib_filefunc_def_s *)" (_imp?open@QuaZip@@QAE_NW4Mode@1@PAUzlib_filefunc_def_s@@@Z) referenced in function "bool __cdecl testCreate(void)" (?testCreate@@YA_NXZ)
    1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall QuaZip::QuaZip(class QIODevice *)" (_imp??0QuaZip@@QAE@PAVQIODevice@@@Z) referenced in function "bool __cdecl testCreate(void)" (?testCreate@@YA_NXZ)
    @

    I have a "quazip" directory with a "zlib" subdirectory, built both of them and then I create a VS project with qmake for each test. I open it in VS2008 SP1, click on "Build" and receive the message that "zlib.h" cannot be found. Obviously the *.pro files are not up-to-date, but whatever, I could also include them manually. So I add the zlib directory to the additional include paths. That error gone, a new one appears:
    @
    1>LINK : fatal error LNK1181: cannot open input file 'quazip.lib'
    @
    That one is funny because I cannot find any quazip.lib in the directories. Then I switch quazip's build configuration to "static library", create that quazip.lib and include it as an additional library. Fixes that error, but then the 14 linker errors from above cross my way.

    Any ideas?

    I have set the include path to fit the includes (they are found, no compiler error), but obviously something else does not work. LNK2019 usually indicates that the implementations cannot be found. However, it should be possible to find them since they reside in the same (included) directory where the header files are.

    Is there a tutorial somewhere on how to include QuaZip step-by-step? Can anyone help me with this issue?

    I badly need QuaZip for my own project to read from and write to archives with a directory structure.

    Any help appreciated, thanks in advance!



  • Obviously something is going wrong while linking QuaZip (It works just fine for me, but I'm using Qt Creator/MinGW). Is is possible that your .lib file is the dynamic stub and not actually the static library (The file size on my system is 112KiB, so if your .lib file is smaller, then it's not the static library)?



  • Actually it is exactly 112 kB as well.

    I just reinstalled everything to have a clean start and copied every source code file from quazip into the test's directory and changed the includes accordingly. Then I am prompted with these "inconsistent dll linkage" errors from the compiler:
    @
    1>------ Build started: Project: zip, Configuration: Debug Win32 ------
    1>Compiling...
    1>moc_quazipfile.cpp
    1>.\debug\moc_quazipfile.cpp(40) : warning C4273: 'staticMetaObject' : inconsistent dll linkage
    1> z:\3dframe\eigenes\quazip\quazip-0.4.1\test\zip\debug../quazipfile.h(67) : see previous definition of 'public: static QMetaObject const QuaZipFile::staticMetaObject'
    1>.\debug\moc_quazipfile.cpp(40) : error C2491: 'QuaZipFile::staticMetaObject' : definition of dllimport static data member not allowed
    1>.\debug\moc_quazipfile.cpp(50) : warning C4273: 'QuaZipFile::metaObject' : inconsistent dll linkage
    1> z:\3dframe\eigenes\quazip\quazip-0.4.1\test\zip\debug../quazipfile.h(67) : see previous definition of 'metaObject'
    1>.\debug\moc_quazipfile.cpp(55) : warning C4273: 'QuaZipFile::qt_metacast' : inconsistent dll linkage
    1> z:\3dframe\eigenes\quazip\quazip-0.4.1\test\zip\debug../quazipfile.h(67) : see previous definition of 'qt_metacast'
    1>.\debug\moc_quazipfile.cpp(63) : warning C4273: 'QuaZipFile::qt_metacall' : inconsistent dll linkage
    1> z:\3dframe\eigenes\quazip\quazip-0.4.1\test\zip\debug../quazipfile.h(67) : see previous definition of 'qt_metacall'
    ........ (and many many more) ..........
    @
    This is really freaky.

    I then tried to eliminate all EXPORT statements which reduced most of the warnings and errors, but left me with some others. Maybe Visual Studio is interfering with something here because I really tried hard to run the out-of-the-box version of QuaZip tests, but none of them worked.

    As I was neither able to find the exact cause nor to fix the errors, I decided to reject QuaZip for as long as I do not badly need its IO-Device support. Its feature of reading and writing directories is also implemented in other packages such as this one: http://www.codeproject.com/KB/files/zip_utils.aspx
    And I am happy to report that this one worked right from the start and so far seems very straightforward.

    Thanks for your help nevertheless. If there is any solution to the posted problem, I would be more than interested in it.



  • I was mistaken. ZipUtils worked well in its preconfigured environment, but threw errors like mad when I tried to include it in my own project. Pretty much the same can be said for all the other dozen Zip packages I have tested yesterday (what a frustrating day).

    Isn't there a working zip package somewhere that will just need including of header and source (or sth else with detailed instructions) and has an easy-to-grasp syntax?

    It was my understanding that zip and unzip are very basic tasks and that there certainly would be a standard out-of-the-box c++ code or library for that, but obviously I couldn't have been more wrong.



  • To let everybody know who experiences similar problems: After another day, I had figured it out for ZipUtils (probably the solution applies to many other packages). The problem was the charset coding. The original projects are mostly based on MultiByte Charset whereas my application has a Unicode flag for the compiler. Usually, this would have been dealt with by the built-in TCHAR type. As it did not work as expected, I changed all literals and functions (wcsncpy etc.) manually to its unicode counterpart. And now it works =)

    So be sure to check your charset coding (for VS2008) both in Project > Properties > Configuration Properties > General and in the compiler flags (> Command Line).



  • Thanks for reporting back on this caveat! Can be very helpfull indeed.



  • I was just struggling with QuaZIP build on Windows with VisualStudio 2010 and got the same problems.

    What I did:

    1. Used CMake 2.8 to configure QuaZIP and generate VS solution file;
    2. Tried to compile Debug and got missing 'zlib.h' problem;
    3. Added path to Qt copy of zlib (in my case "C:/Qt/4.7.4/src/3rdparty/zlib") to C/C++->General->Additional Include Directories;
    4. That fixed missing 'zlib.h' but then I got "error C2491: dllimport static" issue on QuaZipFile::staticMetaObject;
    5. Checked declaration of QuaZipFile -- it starts with "class QUAZIP_EXPORT QuaZipFile";
    6. Searched for QUAZIP_EXPORT and found it in "quazip_global.h" -- it gets defined as either Q_DECL_EXPORT or Q_DECL_IMPORT based on whether QUAZIP_BUILD is defined or not;
    7. Checked preprocessor definitions for quazip project (C/C++->Preprocessor->Preprocessor Definitions" and found that QUAZIP_BUILD is not defined (it should be) -- instead there is a useless define "quazip_EXPORTS" which was probably supposed to be QUAZIP_BUILD but CMake configuration for VisualStudio is buggy;
    8. Got rid of quazip_EXPORTS and added QUAZIP_BUILD -- now at least Debug configuration builds!

    Haven't done the same change for other build configurations yet.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.