2

I have a c++ program that was originally written in Linux. The program uses functions from the library libzip:

https://libzip.org

I am now working on a windows-based platform in Visual Studio 2017. Everthing works, as I could basically use the same cmake-files as I used on the Linux-platform. However, in Linux I used the package manager to install libzip. I do not have that option in Windows. I somehow need to build a Windows-version for libzip and include the files (header files and lib files) in my CMakeLists.txt file. Can someone help me with a step-by-step guide for this?

  • `Can someone help me with a step-by-step guide for this?` - Wrong site for such questions. As you already have CMake project in Windows, you should have basic knowledge how to build it. Why do not apply the knowledge for `libzip` project? If you will get some specific errors, you may ask here (but google before asking). – Tsyvarev Dec 07 '17 at 09:06
  • Hi. I already know how to build. And it works, if I remove all references to libzip. When i try to use functions of libzip I get errors of the type: fatal error LNK1120: 7 unresolved externals. In the CMakeLists.txt file I have added set(LIBZIP_LIBRARY "xx") set(LIBZIP_INCLUDE_DIR "xx") Where "xx" are the correct directiories to header files and a lib file for libzip I have built. – Jakob Loegstrup Dec 07 '17 at 09:43
  • Well, so the problem is not in building libzip but in using it for your project. "Unresolved externals" means that your forgot to **link** with the library. See [that question](https://stackoverflow.com/questions/8774593/cmake-link-to-external-library/10550334#10550334) about linking to libraries in CMake. – Tsyvarev Dec 07 '17 at 16:14

2 Answers2

3

Take a look at vcpkg. It is a package manger for the Windows platform. It builds and installs many open source libraries for Windows. libzip is mentioned specifically as one of the ports.

catbacker
  • 51
  • 5
  • +1 for vcpkg. It simplified things a lot for me. Also, when I tried searching what all I could install using vcpkg, I found this dev blog which proved quite helpful: [vcpkg-a-tool-to-acquire-and-build-c-open-source-libraries-on-windows](https://devblogs.microsoft.com/cppblog/vcpkg-a-tool-to-acquire-and-build-c-open-source-libraries-on-windows) – ggaur May 28 '22 at 12:21
0

Is it possible for you to use the Nuget Package Manager within Visual Studio?

  1. right click on your solution
  2. select "Manage packages for your solution"
  3. search for libzip
  4. select lipzip and click install
  5. you should now be able to #include "zip.h"
Lenon
  • 66
  • 4