[Interest] zipping with Qt

Elvis Stansvik elvstone at gmail.com
Sat Dec 12 01:49:59 CET 2015


Hi Michael,

2015-12-11 21:44 GMT+01:00 Michael Vetter <jubalh at openmailbox.org>:
> Hello list,
>
> I am developing an application which should have a custom file format
> which in reality will just be a .tar.gz file. In is will be some xml
> files and images. I will need to install such a file and have in in my
> applications data folder.
>
> When looking for how to uncompress and compress files using Qt it seemd
> to me that the best way to do it would be to use zlib and the quazip
> wrapper.
>
> I installed both devel packages via my distributions package manager:
> zypper in quazip-devel zlib-devel
>
> In my .pro file I added:
> LIBS += -lquazip -lz
>
> And in my source files I wanted to test everything with a quick:
> #include <quazip/JlCompress.h>
> ...
> JlCompress::compressDir("/home/user/test/afile.zip",
> "/home/user/test/thedir/");
>
> Which results everytime in a segfault.

Seems to work fine here:

[estan at pyret test]$ cat test.cpp
#include <quazip5/JlCompress.h>

int main(int argc, char *argv[]) {
   JlCompress::compressDir(argv[1], argv[2]);
   return 0;
}
[estan at pyret test]$ cat test.pro
TEMPLATE = app
TARGET = test
LIBS += -lquazip5 -lz
SOURCES += test.cpp
[estan at pyret test]$ qmake
[estan at pyret test]$ make
g++ -c -pipe -O2 -march=x86-64 -mtune=generic -O2 -pipe
-fstack-protector-strong -Wall -W -D_
REENTRANT -fPIC -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I. -isystem
/usr/include/qt -isyste
m /usr/include/qt/QtGui -isystem /usr/include/qt/QtCore -I.
-I/usr/lib/qt/mkspecs/linux-g++ -
o test.o test.cpp
test.cpp:3:14: warning: unused parameter ‘argc’ [-Wunused-parameter]
int main(int argc, char *argv[]) {
             ^
g++ -Wl,-O1 -Wl,-O1,--sort-common,--as-needed,-z,relro -o test test.o
 -lquazip5 -lz -lQt5Gu
i -lQt5Core -lGL -lpthread
[estan at pyret test]$ ./test ../test.zip .
[estan at pyret test]$ ls -l ../test.zip
-rw-r--r-- 1 estan users 8654 12 dec 01.48 ../test.zip
[estan at pyret test]$ unzip -l ../test.zip
Archive:  ../test.zip
 Length      Date    Time    Name
---------  ---------- -----   ----
   31277  2015-12-12 01:48   Makefile
    9248  2015-12-12 01:48   test
     131  2015-12-12 01:46   test.cpp
    4208  2015-12-12 01:48   test.o
      71  2015-12-12 01:47   test.pro
---------                     -------
   44935                     5 files
[estan at pyret test]$

What is the backtrace?

Elvis

>
> Does anybody spot my mistake?
> I dont guess I need to specify include and library paths in the pro
> file since its in the systems standard location?
>
> Hope somebody has an idea about this.
>
> regards,
> Michael
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest



More information about the Interest mailing list