CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Aug 2020
    Posts
    5

    Can't get libzippp working in 64 bit

    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<char>,class std::allocator<char> > __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

    Code:
    #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";
        }
    }
    Last edited by VictorN; May 28th, 2021 at 03:03 AM. Reason: adding CODE tags

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: Can't get libzippp working in 64 bit

    In your project properties try to add the .lib for x64 in the Linker/Input/Additional Dependencies
    Victor Nijegorodov

  3. #3
    Join Date
    Aug 2020
    Posts
    5

    Re: Can't get libzippp working in 64 bit

    Quote Originally Posted by VictorN View Post
    In your project properties try to add the .lib for x64 in the Linker/Input/Additional Dependencies
    Thanks, Victor, but it didn't change anything. I even put the full path in the property.

    If I comment out the ze.readAsText() line it runs fine in 64 bit, meaning that ze.GetName() is recognised. I think that means it can find the .lib without extra properties. The puzzle is - why isn't readAsText() recognised when they're both in the same .lib?

  4. #4
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,824

    Re: Can't get libzippp working in 64 bit

    Use dumpbin /exports filename.lib to see the exported names from the .lib file
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  5. #5
    Join Date
    May 2001
    Location
    Germany
    Posts
    1,158

    Re: Can't get libzippp working in 64 bit

    readAsText is exported by the DLL. I expect more of a compiler setting that causes a difference in the exported symbol and the expected one.

  6. #6
    Join Date
    Aug 2020
    Posts
    5

    Re: Can't get libzippp working in 64 bit

    I've collected the mangled name (I assume that is what it is) from the error message and the lib export and there is one difference (ignoring blank spaces)
    Error says it's looking for:
    ?readAsText@ZipEntry@libzippp@@QEBA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@W4State@ZipArchive@2@K@Z
    Lib exports as:
    ?readAsText@ZipEntry@libzippp@@QEBA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@W4State@ZipArchive@2@_K@Z

    The difference is in the last few chars. Error message ends with @K@Z and the lib export ends with @_K@Z having an extra underscore.

    Is that something that can be controlled by a compiler setting?

  7. #7
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,824

    Re: Can't get libzippp working in 64 bit

    The code that produces the .lib/.dll files needs to be re-compiled with your compiler using the same settings as for your main code. This is C++ 'name mangling'. The whole name must match exactly. This is a reason why exported functions are often exported as 'C' rather than C++ as if exported as 'C' this name mangling doesn't occur.
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured