List Archive

Thread

Thread Index

Message

From: QuentinC <quentinc%cfardel.net@localhost>
To: libzip-discuss%nih.at@localhost
Subject: Re: Building libzip with MinGW-W64
Date: Sun, 8 Mar 2020 18:39:31 +0100


    Hello,


It seems that due to some bug, my previous message has been cut before its end. Sorry if you got it twice.


Hello,

I were looking for a library able to read ans write AES-encrypted zip files for a C++ project, and libzip seems to be pretty good and quite simple to use. However, I have issues building it with MinGW-W64 on windows. Can you help me ?

First of all, please don't tell me to use Visual Studio. I have had bad experience with it in the past and so I want to avoid it. I want to stick to MinGW.

Secondly, I need to tell you that I don't know anything about cmake, what it does, and don't want to care at all about it. Libzip requires it, so I have just downloaded the latest binary version without asking another question. I'm tired about the need to download tools that are used to build other tools and that finally never work, but well; libzeep seem to be pretty nice, I really want to try it out.

I'm on windows 10 64 bits, but am compiling with MinGW-W64 32 bit version because many people are still using 32 bit computers. The goal at the moment is just to buid libzip  and the examples. I'll see how and if I can use libzip in my project later on, once I'm able to experiment a little with the library.

Below are the commands I ran and the parts of the output I feel interesting to show, as well as my observations/trials so far.

Thank you for your answers.

> cmake --version
cmake version 3.16.5
CMake suite maintained and supported by Kitware (kitware.com/cmake).

> g++ --version
g++ (i686-posix-dwarf-rev0, Built by MinGW-W64 project) 8.1.0
Copyright (C) 2018 Free Software Foundation, Inc.

# Now running cmake. OK, this tool seem not to auto-detect that I'm using MinGW, and that zlib and openssl are in the default include directory but OK, I juste have to explicitly tell it.

> cmake -G "MinGW Makefiles" -Wno-dev -DZLIB_INCLUDE_DIR=C:\mingw-w64\i686-8.1.0-posix-dwarf-rt_v6-rev0\mingw32\i686-w64-mingw32\include -DOPENSSL_INCLUDE_DIR=C:\mingw-w64\i686-8.1.0-posix-dwarf-rt_v6-rev0\mingw32\i686-w64-mingw32\include
-- The C compiler identification is GNU 8.1.0
...
-- Could NOT find NETTLE (missing: NETTLE_LIBRARY NETTLE_INCLUDE_DIR)
-- Could NOT find GnuTLS (missing: GNUTLS_LIBRARY GNUTLS_INCLUDE_DIR)
-- Found OpenSSL: C:/Program Files/Common Files/Intel/WirelessCommon/libeay32.dll (found version "1.1.1d")
...
-- Found ZLIB: C:/mingw-w64/i686-8.1.0-posix-dwarf-rt_v6-rev0/mingw32/lib/libzlib.a (found suitable version "1.2.11", minimum required is "1.1.2")
-- Could NOT find BZip2 (missing: BZIP2_LIBRARIES BZIP2_INCLUDE_DIR)
CMake Warning at CMakeLists.txt:237 (MESSAGE):
  -- bzip2 library not found; bzip2 support disabled
-- Could NOT find LibLZMA (missing: LIBLZMA_LIBRARY LIBLZMA_INCLUDE_DIR LIBLZMA_HAS_AUTO_DECODER LIBLZMA_HAS_EASY_ENCODER LIBLZMA_HAS_LZMA_PRESET)
CMake Warning at CMakeLists.txt:249 (MESSAGE):
  -- lzma library not found; lzma support disabled
...
-- Configuring done
-- Generating done
-- Build files have been written to: C:/ProgQ/libzip-1.6.1/libzip-1.6.1

> mingw32-make
Scanning dependencies of target zip
...
CMakeFiles\zip.dir/objects.a(zip_source_filep.c.obj):zip_source_filep.c:(.text+0x79f): undefined reference to `_zip_mkstempm'
collect2.exe: error: ld returned 1 exit status
mingw32-make[2]: *** [lib\CMakeFiles\zip.dir\build.make:1911: lib/libzip.dll] Error 1 mingw32-make[1]: *** [CMakeFiles\Makefile2:265: lib/CMakeFiles/zip.dir/all] Error 2
mingw32-make: *** [Makefile:140: all] Error 2

What should I do ?

OK, so, that's a linking problem. The function _zip_mkstempm isn't found.
It seems that this function is present in lib/zip_mkstempm.c.

Cmake put temporary object files in lib/CMakeFiles/zip.dir.
First problem: I see all *.obj files there, but no _zip_mkstempm.obj. It seems that the file has been skipped.

All right, let's try to compile it myself. I belief that cmake was automagic ?
> gcc -c -s -O3 _zip_mkstempm.c -std=gnu11 -I. -I..

And then, move it and add it into objects.a
> ar ra _zip_mkstempm.o objects.a

Now the build should be able to continue:
> mingw32-make

Exactly the same error. objects.a has probably been overwritten by cmake. Game over.

What should I try next ?

Thank you for your answers.


Le 08.03.2020 à 17:58, QuentinC a écrit :

Hello,

I were looking for a library able to read and write AES-encrypted zip files for a C++ project, and libzip seems to be pretty good and quite simple to use. However, I have issues building it with MinGW-W64 on windows. Can you help me ?

First of all, please don't tell me to use Visual Studio. I have had bad experience with it in the past and so I want to avoid it. I want to stick to MinGW.

Secondly, I need to tell you that I don't know anything about cmake, what it does, and don't want to care at all about it. Libzip requires it, so I have just downloaded the latest binary version without asking another question. I'm tired about the need to download tools that are used to build other tools and that finally never work, but well; libzeep seem to be pretty nice, I really want to try it out.

I'm on windows 10 64 bits, but am compiling with MinGW-W64 32 bit version because many people are still using 32 bit computers. The goal at the moment is just to build libzip  and the examples. I'll see how and if I can use libzip in my project later on, once I'm able to experiment a little with the library.

Below are the commands I ran and the parts of the output I feel interesting to show, as well as my observations/trials so far.

Thank you very much for your answers.

> cmake --version
cmake version 3.16.5
CMake suite maintained and supported by Kitware (kitware.com/cmake).

> g++ --version
g++ (i686-posix-dwarf-rev0, Built by MinGW-W64 project) 8.1.0
Copyright (C) 2018 Free Software Foundation, Inc.

# Now running cmake. OK, this tool seem not to auto-detect that I'm using MinGW, and that zlib and openssl are in the default include directory but OK, I juste have to explicitly tell it.

> cmake -G "MinGW Makefiles" -Wno-dev -DZLIB_INCLUDE_DIR=C:\mingw-w64\i686-8.1.0-posix-dwarf-rt_v6-rev0\mingw32\i686-w64-mingw32\include -DOPENSSL_INCLUDE_DIR=C:\mingw-w64\i686-8.1.0-posix-dwarf-rt_v6-rev0\mingw32\i686-w64-mingw32\include
-- The C compiler identification is GNU 8.1.0
.

Made by MHonArc.