-
May 27th, 2021, 08:55 PM
#1
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
-
May 28th, 2021, 03:08 AM
#2
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
-
May 28th, 2021, 07:03 PM
#3
Re: Can't get libzippp working in 64 bit
Originally Posted by VictorN
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?
-
May 29th, 2021, 04:14 AM
#4
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)
-
May 30th, 2021, 11:37 AM
#5
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.
-
June 1st, 2021, 01:41 AM
#6
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?
-
June 1st, 2021, 03:31 AM
#7
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|