Comments (9)
from bit7z.
Hi!
I see from the code that you're using p7zip's 7z.so
on Linux.
By default, bit7z uses the latest 7-Zip implementation of the Windows COM interfaces, which is incompatible with p7zip's (since 7-Zip v23.01).
This leads to problems like yours, where the 7z.so
uses one implementation, and bit7z another, resulting in a crash.
You can build bit7z to be compatible with the p7zip's 7z.so
by enabling the CMake option BIT7Z_USE_LEGACY_IUNKNOWN
; this should fix your problem.
from bit7z.
from bit7z.
I see.
I'll try to replicate the issue
from bit7z.
from bit7z.
Unfortunately, I wasn't able to replicate the issue.
Specifically:
-
As I don't have access to RHEL 8, I've set up a VM running Fedora 28 (which is the base for RHEL 8).
-
For the tests, I've used the default GCC version (8.3.1), the default p7zip's 7z.so (package
p7zip-plugins
), and the default Qt 5 development packages provided on Fedora 28. -
Inside the VM, I've built bit7z as follows:
git clone https://github.com/rikyoz/bit7z && cd bit7z mkdir build && cd build cmake .. -DBIT7Z_AUTO_FORMAT=ON -DBIT7Z_USE_LEGACY_IUNKNOWN=ON cmake --build . --config Release
-
Always inside the VM, I created a barebone Qt 5 Widgets application project in Qt Creator that uses the bit7z library built as in the previous step.
- I've done this to try replicate your issue, as it seems that your code is part of a Qt application.
-
- The first
QLineEdit
andQPushButton
couple allows to select the directory to be compressed. - The second one allows to select the destination archive.
- The last
QPushButton
executes your code, which I wrapped inside a method of a dummyCompressor
class:
// compressor.h class Compressor { QString m; public: const QString& resultMessage() { return m; } bool compressDirectory(const QString& dir, const QString& archivePath) { try { using namespace bit7z; #ifdef Q_OS_WINDOWS Bit7zLibrary lib("C:/Program Files/7-Zip/7z.dll"); #else Bit7zLibrary lib("/usr/libexec/p7zip/7z.so"); #endif if (archivePath.endsWith(".zip", Qt::CaseInsensitive)) { BitArchiveWriter archive(lib, BitFormat::Zip); archive.setUpdateMode(UpdateMode::Update); archive.addDirectory(dir.toStdString()); archive.compressTo(archivePath.toStdString()); } else { BitArchiveWriter archive(lib, BitFormat::SevenZip); archive.setUpdateMode(UpdateMode::Update); archive.addDirectory(dir.toStdString()); archive.compressTo(archivePath.toStdString()); } m = "Successfully compressed directory [" + dir + "] to archive [" + archivePath + "]"; return true; } catch ( const bit7z::BitException& ex ) { /* Do something with ex.what()...*/ m = "Unable to compress directory into archive using bit7z library [" + QString(ex.what()) + "]"; return false; } } }; // mainwindow.cpp void MainWindow::on_pushButton_clicked() { Compressor compressor; bool result = compressor.compressDirectory(ui->directoryLineEdit->text(), ui->archiveLineEdit->text()); if (result) { QMessageBox::information(this, tr("Compression successful"), compressor.resultMessage(), QMessageBox::Ok); } else { QMessageBox::critical(this, tr("Compression error"), compressor.resultMessage(), QMessageBox::Ok); } }
- The first
-
I've tested the code both by creating a Zip and a 7z archive, and it worked in both cases, without any crash:
from bit7z.
It worked! (once) I was using the 4.0.4 code and I updated to the 4.0.6, rebuilt it, and it worked. My program built, it ran, and created a .7z file successfully.
However, after that one time working, now my program doesn't build correctly :-( I don't know what changed, but now every time I build my program against the bit7z library I get this error
linking nidb
../../bin/squirrel//libsquirrel.so: undefined reference to `bit7z::BitInputArchive::ConstIterator::operator*()'
collect2: error: ld returned 1 exit status
make: *** [Makefile:353: nidb] Error 1
In my case nidb
depends on libsquirrel
which depends on libbit7z64
. I'm able to build the libsquirrel library, which depends on bit7z. But when trying to build any executable that depends on bit7z, I get link errors like these:
linking squirrel
squirrel.o: In function `squirrel::RemoveDirectoryFromArchive(QString, QString, QString&)':
squirrel.cpp:(.text+0x18171): undefined reference to `bit7z::BitInputArchive::ConstIterator::operator*()'
squirrel.cpp:(.text+0x18399): undefined reference to `bit7z::BitInputArchive::ConstIterator::operator*()'
squirrel.o: In function `bit7z::BitExtractor<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&>::extractMatching(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::vector<unsigned char, std::allocator<unsigned char> >&, bit7z::FilterPolicy) const':
squirrel.cpp:(.text._ZNK5bit7z12BitExtractorIRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEE15extractMatchingES8_S8_RSt6vectorIhSaIhEENS_12FilterPolicyE[_ZNK5bit7z12BitExtractorIRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEE15extractMatchingES8_S8_RSt6vectorIhSaIhEENS_12FilterPolicyE]+0xaf): undefined reference to `bit7z::BitInputArchive::ConstIterator::operator*()'
collect2: error: ld returned 1 exit status
make: *** [Makefile:313: squirrel] Error 1
from bit7z.
Now it works, consistently. Building bit7z from scratch solved my problem. Thank you!
from bit7z.
Building bit7z from scratch solved my problem.
The recent v4.0.6 fixed the operator*
of the BitInputArchive
's iterator, which couldn't be called on const iterator objects.
There was probably a mismatch between your bit7z's headers and binary, which was fixed by rebuilding it.
Thank you!
You're welcome!
Thank you for using bit7z! 🙏
from bit7z.
Related Issues (20)
- [build-error]: Failed to open the archive file: No such process HOT 2
- [Bug]: UpdateMode::Update not working as expected, throwing exception HOT 3
- [Feature Request]: Creation or extraction archive file in one line HOT 1
- [Feature Request]: Support for compressed packages in four formats: ace, img, uue, and war HOT 2
- [Feature Request]: Extracting files whose names contain forbidden characters HOT 1
- Do I need to build 7zip myself? HOT 6
- [Bug]:
- [Bug]: Multiple Definition Linker Error for IID_IUnknown HOT 10
- [Bug]: BIT7Z_DISABLE_USE_STD_FILESYSTEM not working HOT 4
- [Bug]: Compile error when bit7z.lib is introduced into the project. HOT 11
- [Feature Request]: Is "tstring_to_path" forgotten here? HOT 1
- [Bug]: HOT 3
- [Feature Request]: Compresses files open for writing by another applications HOT 1
- [Bug]: CreateObject 函数调用异常
- [Bug]: Some zip file names are garbled HOT 5
- [Bug]: HOT 3
- [Possible Bug]: BitArchiveReader::items is slow? HOT 6
- [Feature Request]: Link static 7z lib HOT 1
- [Bug]: Inconsistent encoding of string parameter HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bit7z.