1

I'm looking for Zip libraries and libzippp looks to be what I want so I'm trying little POC console apps.
This is the first, which works fine in x86 but when I try to compile in x64 I get 'Unresolved External readAsText'.
I used vcpkg to get the libraries
vcpkg install libzippp
vcpkg install libzippp:x64-Windows

Error LNK2019 unresolved external symbol "public: class std::basic_string<char,struct std::char_traits,class std::allocator > __cdecl libzippp::ZipEntry::readAsText(enum libzippp::ZipArchive::State,unsigned long)const " (? readAsText@ZipEntry@libzippp@@QEBA ? AV ? $basic_string@DU ? $char_traits@D@std@@V ? $allocator@D@2@@std@@W4State@ZipArchive@2@K@Z) referenced in function main Zip6 D : \rcodeNET\Dev\Zip6\Zip6.obj 1


#include <iostream>
#include "libzippp\libzippp.h"
using namespace std;
using namespace libzippp;

int main()
{
    ZipArchive zf("d:\\1zip\\Gender.zcd");
    bool ok = zf.open(ZipArchive::ReadOnly);

    vector<ZipEntry> entries = zf.getEntries();

    ZipEntry ze;
    for (int i = 0; i < entries.size(); i++)
    {
        ze = entries[i];
 
        string name = ze.getName();
        int size = ze.getSize();
        std::cout << name << "=" << size << "\n";

        string textData = ze.readAsText();
        std::cout << "text " << textData << "\n";
    }
}
Roland17
  • 13
  • 4
  • Does this answer your question? [What is an undefined reference/unresolved external symbol error and how do I fix it?](https://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) – Ken White May 28 '21 at 02:48
  • Not really, a bit too general. I have another clue, though. The error message above gives the full mangled name (I think that's what it is) that it is looking for as: ?readAsText@ZipEntry@libzippp@@QEBA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@W4State@ZipArchive@2@K@Z and the lib is exporting the function as ?readAsText@ZipEntry@libzippp@@QEBA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@W4State@ZipArchive@2@_K@Z There's one character different in the last few chars: the error message ends @K@Z and the lib export ends @_K@Z – Roland17 Jun 01 '21 at 06:45
  • Did you fix this issue? I have the same issue when using Conan package. – user1633272 Aug 14 '21 at 11:04
  • I sort of worked around it. The package worked fine in 32 bit but got mismatch in 64. Just on a whim I tried a console app that didn't bother with using the libzippp package. I just included the source code, which I found in the vcpkg directories in D:\vcpkg\vcpkg-master\buildtrees\libzippp\src\32217e672c-26e2865e9c.clean\src Just two files, libzippp.cpp/.h. I copied them to my source dirs, included in the project, compiled it and it worked. It pulls in a few vcpkg dependencies but not the libzippp package so I circumvented the mismatch. – Roland17 Aug 18 '21 at 00:37

1 Answers1

0

I think I figured it out, one should add WIN32 into preprocessor definitions of the project.

user1633272
  • 2,007
  • 5
  • 25
  • 48