NO

Author Topic: How to compile libzip  (Read 5078 times)

GaborK

  • Guest
How to compile libzip
« on: November 17, 2019, 09:58:59 PM »
I would like to compile libzip for Pelles C in Windows 7. I downloaded libzip from https://libzip.org/download/libzip-1.5.2.tar.gz, and I tried to install it, following the instructions in INSTALL.md. For that reason,
  • I downloaded cmake from https://github.com/Kitware/CMake/releases/download/v3.16.0-rc3/cmake-3.16.0-rc3-win64-x64.zip,
  • I unzipped the zip archive,
  • I added the <path to the bin directory in the extracted zip file> to the %PATH% environment variable,
  • I added the <path to Pelles C bin folder> to the %PATH% environment variable,
  • I created a %CC% environment variable with the <path to Pelles C bin folder>, which contains cc.exe,
  • in the Command Prompt
    • I created a folder, called build ('mkdir build')
    • 'cd build'
    • 'cmake ..'
The output is below:

Quote
CMake Error at C:/Program Files/cmake-3.16.0-rc3-win64-x64/share/cmake-3.16/Modules/CMakeDetermineCCompiler.cmake:49 (message):
  Could not find compiler set in environment variable CC:

  C:\Program Files\PellesC\Bin.
Call Stack (most recent call first):
  CMakeLists.txt:8 (PROJECT)

CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!
See also "C:/Users/[......]/build/CMakeFiles/CMakeOutput.log".

Could you please give me step by step instructions on how to compile libzip, and arrange that I can use libzip functions in my C code?

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2113
Re: How to compile libzip
« Reply #1 on: November 18, 2019, 05:10:04 PM »
The environment variables must be set globally, not in a CMD window, in which case the settings would be only local to the current consolle.
In any case PellesC don't works well with cMake, even command switch could be conflicting with those of GCC.
The correct way is to expand source files in a directory and then build an IDE project adding the necessary files.
If a VC project is present you can use the wizard to import it in a PellesC project.
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide

GaborK

  • Guest
Re: How to compile libzip
« Reply #2 on: November 18, 2019, 09:21:34 PM »
Thank you for the reply.
I set the environment variables globally, in the Control Panel. If I open a Command Prompt, the output of
Code: [Select]
echo %PATH% is always correct.
Could you please elaborate a bit more on
  • what kind of IDE project I should build (e.g. Win64 Static Library (LIB)),
  • what are the "necessary files" I should add to it,
  • how to add those files to the project, and
  • how to build the project.
Actually, I created a new "Win64 Static Library (LIB)" project, and I tried to add *.c files to it from the unzipped folder, using 'Project -> Add files to project...' but an error message appeared:
Quote
Unable to add '*.c' to the project. Unknown file extension, or invalid directory.
I found it rather strange because files with .c extension are listed in the pop-up window by default.
I also tried adding the <path to the unzipped folder> to the "Includes" in the 'Project -> Project options... -> Folders tab' but it didn't solve my problem either. At runtime, a lot of error messages appeared about zip.h.
Pleaseee try to be a bit more specific, I am a beginner at Pelles C.

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2113
Re: How to compile libzip
« Reply #3 on: November 19, 2019, 11:07:19 AM »
Normally tou should know what you want build, a library, static or dynamic, or an exe.
The info about what file you need could be found inside makefiles (or cmake files).
I'm a little bit busy myself, if you can wait I'll have a look.
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide

Offline John Z

  • Member
  • *
  • Posts: 860
Re: How to compile libzip
« Reply #4 on: November 29, 2019, 01:51:18 PM »
Would you consider using another ZIP library?  I've used miniz in PellesC windows 7 version 8.00, and now windows 10 PellesC version 9.00 - it is quite easy, only three files to add to your existing project. I got it from here https://github.com/richgel999/miniz.  Just added two .h files and one zip.c to my program.  I looked at libzip, and many others too, but went with this one as being much easier to implement.