libzip with Visual Studio 2010 - c++

How can I compile libzip for Visual Studio 2010?

Edit:
Before starting on the answer provided here, it appears that this may no longer be an issue going by #Thomas Klausner's answer below.
The following should get you a VS10 solution:
If you've not already done so, install CMake
Download and extract zlib to e.g. C:\devel. The download links are about halfway down the homepage. Currently this provides zlib version 1.2.7.
To work around this CMake bug which affects 64-bit Windows only, add
if(CMAKE_SIZEOF_VOID_P EQUAL 8 AND MSVC)
set_target_properties(zlibstatic PROPERTIES STATIC_LIBRARY_FLAGS "/machine:x64")
endif()
to the end of C:\devel\zlib-1.2.7\CMakeLists.txt
Download and extract libzip to e.g. C:\devel
In a VS10 command prompt, cd C:\devel\zlib-1.2.7
mkdir build && cd build
cmake .. -G"Visual Studio 10" -DCMAKE_INSTALL_PREFIX="C:\devel\installed\zlib" This sets the install path to C:\devel\installed\zlib rather than the default C:\Program Files\zlib. For 64-bit Windows, use "Visual Studio 10 Win64" as the -G parameter.
msbuild /P:Configuration=Debug INSTALL.vcxproj
msbuild /P:Configuration=Release INSTALL.vcxproj
cd C:\devel\libzip-0.10.1
mkdir build && cd build
cmake .. -G"Visual Studio 10" -DCMAKE_PREFIX_PATH="C:\devel\installed\zlib" Set the path to wherever you installed zlib so that CMake can find zlib's include files and libs. Again, for 64-bit Windows, use "Visual Studio 10 Win64" as the -G parameter.
This should result in C:\devel\libzip-0.10.1\build\libzip.sln. It looks like there are a few POSIX-specific problems in the code, but they should hopefully be fairly easy to resolve (e.g. in zipconf.h #include <inttypes.h> needs replaced with #include <stdint.h>; there are some snprintf calls needing replaced e.g. with _snprintf).

I can't comment, so just in addition to Fraser's answer: In the last days, libzip's latest repository version should compile on VS without additional patches. Please try it out and let the developers know if parts are still missing.

Can't comment on answer above but was trying to get this to work and in the end found that the Output directory under the configuration properties and the comand in debugging.
You can remove ALL_BUILD, ZERO_CHECK, INSTALL and PACKAGE and it will build fine without any of the linking errors or linux specific errors.

Using libzip-1.0.1, zlib-1.2.8, and VS Community 2013.
Added to path:
C:\Program Files (x86)\CMake\bin;C:\Windows\Microsoft.NET\Framework64\v4.0.30319
The cmake line became:
cmake .. -G"Visual Studio 12 Win64" -DCMAKE_INSTALL_PREFIX="C:\devel\installed\zlib"
devel\libzip-1.0.1\lib\zip_source_filep.c:189 changed:
mask = umask(S_IXUSR | S_IRWXG | S_IRWXO);
to:
mask = umask(_S_IREAD | _S_IWRITE);

Using
an environment variable %ZLIB_DIR% for the path to zlib-1.2.8,
%LIBZIP_DIR% for the path to libzip-1.0.1
VS 2015 Express Edition, and
the file %LIBZIP_DIR%/lib/zip_source_filep.c patched according to http://hg.nih.at/libzip/rev/80457805a1e7 ,
the process for building zlib and libzip becomes this:
Building zlib
> cd /d %ZLIB_DIR% && md build & cd build
> cmake .. -G"Visual Studio 14 2015 Win64"- DCMAKE_INSTALL_PREFIX="%ZLIB_DIR%"
> msbuild /P:Configuration=Debug INSTALL.vcxproj
> msbuild /P:Configuration=Release INSTALL.vcxproj
Building libzip
> cd /d %LIBZIP_DIR% && md build & cd build
> cmake .. -G"Visual Studio 14 2015 Win64" -DCMAKE_PREFIX_PATH="%ZLIB_DIR%"
> msbuild /P:Configuration=Debug ALL_BUILD.vcxproj
> msbuild /P:Configuration=Release ALL_BUILD.vcxproj
Done!
(So you see, #MikeLischke, CMake does indeed work out-of-the-box sometimes...)

In current zlib version, there is a contrib for this:
zlib-1.2.8\contrib\vstudio\vc10\zlibvc.sln
I got an error on load because one of the configurations wasn't valid on my machine, but a recompile took care of that. I also had to change the project properties>Configuration Properties>Linker>Input>Additional Dependencies for the Debug configuration to change zlibwapi.lib to zlibwapid.lib.

In Visual Studio 2015, Win64:
If building libzip failing with a message like this:
Could NOT find ZLIB (missing: ZLIB_LIBRARY) (found version "1.2.8").
All you have to do is copy the generated 'zlib.dll/zlibd.zll' and 'zlib.lib/zlibd.lib' to the top of the zlib directory (where the .h/.c files are).

The answer given by Christian Severin helped me a lot, but needed some updates for VS2019 and 32-bit:
When building with VS 2019, you must use the -A option, not use "Win64".
When building with VS 2019, the 32-bit archive is "Win32", not x86.
The "Building zlib" section has a typo, it must be Win64" -DCMAKE_..., with a space before the dash
Here is a working example with VS2019 and 32-bit build:
cd /d %ZLIB_DIR% && md build & cd build
cmake .. -G"Visual Studio 16 2019" -DCMAKE_INSTALL_PREFIX="%ZLIB_DIR%" -AWin32
msbuild /P:Configuration=Release INSTALL.vcxproj
cd /d %LIBZIP_DIR% && md build & cd build
cmake .. -G"Visual Studio 16 2019" -DCMAKE_INSTALL_PREFIX="%ZLIB_DIR%" -AWin32
msbuild /P:Configuration=Release ALL_BUILD.vcxproj

Related

Compiler out of heap space and MSBuild 32 bit

I'm trying to compile the library OpenGV and I get the error MSVC C1060 "compiler out of heap space".
I tried to go change to x64 architecture by adding
<PreferredToolArchitecture>x64</PreferredToolArchitecture>
<PlatformTarget>x64</PlatformTarget>
to the .vxcproj file, without success. I notice however that in the resource manager, MSBuild 32 bit is still being used. Could this be the problem, and if so, how can I change the build tool (i.e. the MSbuild version), through, say, GitBash?
If you're compiling the project through the Visual Studio IDE, the Visual Studio IDE silently uses a 32-bit compiler. To change this behavior, use the command:
msbuild {solution-name}.sln /property:Configuration=Release"
To find the path to the msbuild command on your system, use the command below:
where msbuild
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe
If the where msbuild command does not return a path like C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe, but your system has msbuild installed, go to the system variables and add the MSBuild.exe path to the system path in the file structure where Microsoft Visual Studio is installed. Remove other msbuild path variable from system variables (like C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe). Otherwise, this change may not work.
In another graphics library (solution, issue) it is reported how to solve a similar problem and its solution is reported as solved as above.
When installing OpenGV under Window it is stated in the documentation that the msbuild configuration should be changed as follows:
msbuild opengv.sln /p:Configuration=Release
In addition, if the cmake build tool will be used in the project, the following declaration should be made using the -G option to compile for x64 target machine:
cmake -G "Visual Studio 16 2019" -A x64 ../
# cmake -G "Visual Studio 16 2019" -A Win32 ../
# cmake -G "Visual Studio 16 2019" -A ARM ../
# cmake -G "Visual Studio 16 2019" -A ARM64 ../

cmake incremental build with vs 2015 and llvm-vs2014 toolset

When i use VS 2015 with llvm-vs2014 toolset on my project (project generated by cmake 3.9) the incremental build is not available: if i restart build or modify only one cpp file, the whole solution is built and it takes time...
In this case, incremental build is not available in VS2015 ? How can i activate it.
An example of my toolchain commands:
cmake -G"Visual Studio 14 2015" -T"LLVM-vs2014" myBuild
msbuild myBuild.sln /t:myPrpoject /maxcpucpunt
I tried to modify msbuild parameters but nothing happen

How to install pbrt-v3 on windows10 with Visual Studio 2017?

I fork the repo and download it, then open it in the Visual Studio 2017 community and did as follows:
1:right-click the MakeLists.txt and click the Rebuild All. (x64 Debug)
2:Then, i found the build directory at here:C:\Users\SHIZU-NOTEBOOK\AppData\Local\CMakeBuild\233159a3-9dca-9735-91fc-be7911e3ef6d\build\x64-Debug\Debug
I can't find the directory like *\bin, also in cmd "pbrt" dosen't work.
Am I wrong with build?and solution!
Sincerely!
Use the cmake-gui or cmake command line tool to generate Visual Studio solution file, then build the solution.
If you choose the command line, here are steps:
Generate solution files
mkdir build && cd build
cmake .. -G "Visual Studio 15 Win64"
Now, open PBRT-V3.sln with Visual Studio 2017
Buile the solution
PS: from the readme in pbrt-v3 project, you need run git submodule update --init --recursive to fetch the dependencies.

Compiling Cling with Visual Studio

I am trying to build cling for Windows using Visual Studio. After all the steps were completed as shown below, I don't seem to have the cling.exe in the directory /cling/build/Debug/bin for some reason. There's a clang.exe, clang++.exe and a bunch of random llvm ones but it seems that only cling.exe is missing. Does anyone know if I am missing some steps or what went wrong?
// Install CMake 3.6.0 and Visual Studio Express 2015 for Windows desktop
git clone root.cern.ch/git/llvm.git src
cd src
git checkout cling-patches
cd tools
git clone root.cern.ch/git/cling.git
git clone root.cern.ch/git/clang.git
cd clang
git checkout cling-patches
cd ../..
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=[Install Path] ..\src -G "Visual Studio 14"
//Go inside build directory and open LLVM.sln, run "Build Solution" on "Debug" and "Win32"
I guess it doesn't work for Windows currently but it will be ready in a couple of week.
https://root.cern.ch/phpBB3/viewtopic.php?f=21&t=22006&sid=b9bc976106f30bdd02d48427a88aa04e

visual studio build application from the source code

I have an application to build using the code source but i have a problem with that because i didn't understand what they mean by:
On Windows, add -G "Visual Studio 14 Win64". Also, you will probably
need to add -C ../4dface/initial_cache.cmake as first argument -
copy the file from initial_cache.cmake.template and adjust the
paths.
Here is the third step which i can't realize it:
3.
Build the app:
Run from outside the source directory:
1. mkdir build && cd build
2. `cmake -DCMAKE_INSTALL_PREFIX=../install -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=gcc-5 -DCMAKE_CXX_COMPILER=g++-5 -DOpenCV_haarcascades_DIR=/usr/share/opencv/haarcascades/ ../4dface/`
On Windows, add `-G "Visual Studio 14 Win64"`. Also, you will probably need to add `-C ../4dface/initial_cache.cmake` as first
argument - copy the file from initial_cache.cmake.template and
adjust the paths.
If you get an error about OpenCV\_haarcascades\_DIR, adjust `-DOpenCV_haarcascades_DIR` to point to the directory of
haarcascade_frontalface_alt2.xml from OpenCV.
I am on windows 8 and i had the code source from this "https://github.com/patrikhuber/4dface"
and here is the link for the readme "https://github.com/patrikhuber/4dface/blob/master/README.md"
Thank you.
Looks like you need to use CMake. Install it.
From the Visual Studio "Tools" Menu, choose "Visual Studio Command Prompt".
In the window, change directories to the project.
Now enter the command "CMake -G "Visual Studio 14 2015 Win64".
Note: Cmake wants the "2015" in the phrase.