CMake zlib Dependency Error on Windows - c++

I'm trying to build OpenEXR 2.2 on Windows, but the instructions that came with the download aren't working as expected. The instructions for IlmBase worked, but once I get to the OpenEXR instructions, it fails because of zlib. The steps at this point are:
3. Go to http://www.zlib.net and download zlib
So I went to this website and in the section that starts with: The current release is publicly available here: I downloaded zlib source code, version 1.2.8, zipfile format...
Then, I moved on to the next step, which is where I get the error:
4. Launch a command window, navigate to the OpenEXR folder with
CMakeLists.txt, and type command:
setlocal
del /f CMakeCache.txt
cmake
-DZLIB_ROOT=<zlib location>
-DILMBASE_PACKAGE_PREFIX=<where you installed the ilmbase builds>
-DCMAKE_INSTALL_PREFIX=<where you want to instal the openexr builds>
-G "Visual Studio 10 Win64" ^
..\openexr
So here's the command I type:
cmake -DZLIB_ROOT=C:\Users\erik\Documents\zlib-1.2.8 -DILMBASE_PACKAGE_PREFIX=C:\Users\erik\Documents\ilmbase-2.2.0\bin -DCMAKE_INSTALL_PREFIX=C:\Users\erik\Documents\ilmbase-2.2.0\bin -G "Visual Studio 10 Win64" ^..\openexr-2.2.0
And here's the error I get:
Could NOT find ZLIB (missing: ZLIB_LIBRARY) (found version "1.2.8")
First problem is, the instructions don't say anything about ZLIB_LIBRARY. Second is, the zlib download looks like it's all source code. No .lib or .dll files are involved.

You have downloaded only the source code. You need to compile it first. Or download the pre-compiled DLL: "zlib compiled DLL" from the zlib homepage.
ZLIB_LIBRARY will be derived from ZLIB_DIR, so this part is correct.

Related

`Could not find feature system-zlib` during building QT source code

I'm trying to build QT from source code in Windows.
I installed QT binary (5.12.8) to get qmake, the bin path is added to system environment.
I downloaded QT source code (qtbase only) tag v5.12.8 and unzip to d:\github\qtbase
I opened the vs native x64 cmd shell and run: qmake qtbase.pro
The output is like:
Support enabled for:
Using pkg-config ....................... no
udev ................................... no
Using system zlib ...................... no
.
.
.
Qt is now configured for building. Just run 'nmake'.
Once everything is built, you must run 'nmake install'.
Qt will be installed into 'C:\Qt\Qt5.12.8\5.12.8\msvc2017_64'.
then I run nmake but I had this error:
Project ERROR: Could not find feature system-zlib.
NMAKE : fatal error U1077: 'cd' : return code '0x3'
Stop.
From the config log above, system zlib is not used, I assume QT's internal zlib will be used.
I have checked my folder, \src\3rdparty\zlib\src is existed and zlib.h is there.
I'd like to know how to fix this error or disable zlib.
#AlanBirtles Thanks for the hint, I followed the official instructions and compiled again, it works.
In the official instruction, configure.bat is used instead of my direct use of qmake.
There is one more difference in my second try: I use the src code in C:\Qt\Qt5.12.8\5.12.8\Src, not the code from github in d:\github\qtbase.
The code in C:\Qt is downloaded during my installation of binary QT, because I checked the source code item in the installation.

Build OpenCV for UWP

I'm currently struggling to build OpenCV for the UWP.
I already googled quite a lot and found Microsoft's OpenCV Github Repo which tecnically should do the magic. However, this repo and pretty much everything else I found in this regard are outdated (Visual Studio 2015, old OpenCV versions etc.). I need to use OpenCV 3.3 because it's a cross platform project and I don't want to recompile everything else solely because of an outdated git repo.
Can anyone explain the process of building OpenCV using CMake from the official repo for the UWP?
My first attempt was to simply use the Windows Dlls, however my application than shouts "Failed to load module" at me. Then, I tried to build OpenCV the Visual Studio Project files as stated here and here. However, this doesn't do it for me as it throws the following error:
CMake Error at cmake/OpenCVUtils.cmake:440 (if):
if given arguments:
"(" "OR" "OFF" ")"
Unknown arguments specified
Call Stack (most recent call first):
CMakeLists.txt:317 (OCV_OPTION)
It also tells me to check the CMakeOutput.log but there it's 0 errors everywhere.
If someone could tell me either how to get rid of this error or what to change in the CMake GUI to build OpenCV for UWP, that'd be great!
Edit:
I also tried to compile OpenCV with a platform specific toolchain for WinRT as found in platforms/winrt. It doesn't really change anything though (I'm not even sure if it should), I still get "Unable to load Dll: The specified module could not be found". Maybe GPPK is right in his assumption that it's more an UWP problem than an OpenCV one. Anyways, if anyone knows anything about this, I'd really love to get some help!
Ok, I didn't get an answer yet, so I managed to do it myself (more or less).
Here's how I did it:
Prerequisites
Visual Studio (2017)
UWP SDK
CMake
OpenCV from official repo
Steps
Create a build folder which you want the UWP libraries to built in.
Start PowerShell in this folder and execute the following command (exchange C:\OpenCV with your local OpenCV path): cmake -G "Visual Studio 15 2017" -DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERS
ION="10.0" -DCMAKE_VS_EFFECTIVE_PLATFORMS=x86 -DBUILD_TESTS=OFF -DBUILD_PERF_TESTS=OFF C:\OpenCV
If you get the same error message as I did (see question for more details), go to the root CMakeLists.txt in the OpenCV folder and add a # in front of line 317 (OCV_OPTION(ENABLE_PYLINT)). This should fix it, to check, execute the command from above once more.
Ensure that the output claims "Windows RT support YES" and "Building for Microsoft platform: Windows".
Open OpenCV.sln in the build folder. Ensure that all projects are either of type "Windows Store" or "Universal Windows" and build the ALL_BUILD Project twice: Once in Release configuration, and once in Debug. Then build the INSTALL Project.
That's it, you should find the built Dlls in the install folder. Step 3 is probably a bug in OpenCV and will hopefully be fixed in upcoming versions.

How to compile GMP for windows using Visual Studio

I am trying to install gmp on windows. I have found the mingw way of compiling from sources on windows.
But was unable to find binaries fro gmp 6.1.2 or visual studio project in order to compile from sources.
So the question is: Where can I download the gmp 6.1.2 binaries or compile from sources using Visual Studio.
I'll describe three ways of compiling GMP in Windows.
First
Install Visual Studio 2022 Community from this page.
Install VCPKG package manager as described here, basically just do two steps:
git clone https://github.com/Microsoft/vcpkg --depth=1
inside vcpkg directory run
cmd /c bootstrap-vcpkg.bat
Set system environment variable VCPKG_DEFAULT_TRIPLET=x64-windows-static, for doing this press WinKey+Pause, then click "Advanced system settings", then "Environment variables", inside "System variables" click "New" and set value of VCPKG_DEFAULT_TRIPLET to x64-windows-static.
Instead of this step above (setting variable) you can just pass triple directly to all vcpkg commands like vcpkg install gmp --triplet=x64-windows-static.
Inside git directory of vcpkg run following command:
vcpkg install gmp --triplet=x64-windows-static
(you may omit --triplet=x64-windows-static if you set environment variable as I told above)
It will take quite a lot of time, it will compile many packages from sources.
After full compilation is finished it will show in console path to ZIP file with compiled GMP library. On my system ZIP file was created at C:\Users\user\AppData\Local\vcpkg\archives\8d\8d1c08fabf677187083dedd12d6accf7114d91580e75611c065f1674b600bee9.zip.
Unpack this ZIP file and then you can compile your C++ program like following:
cl program.cpp /O2 /GL /EHsc /std:c++latest /Ipath_to_unpacked_zip/include/ path_to_unpacked_zip/lib/gmp.lib
As you might know cl command should be run from "x64 Native Command Prompt" command shell which can be found in "Windows Start Menu / Visual Studio 2022 /".
Also you may install MPIR instead of GMP, this is a fork of GMP, with same interface, but more preferred by Windows users. Just do vcpkg install mpir, but this can be done only if you delete GMP package first, only one of MPIR or GMP can be installed.
Second
This step doesn't compile GMP, but uses precompiled binaries from MinGW installation.
Install Visual Studio as in first step.
Go to home page of MSYS2. Download installer, link is located near "1. Download the installer:" phrase. Install it to any location, e.g. c:\bin\msys\.
After installation in Windows Start Menu go to application "MSYS2 64bit" and inside it start program "MSYS2 MSYS", it will run Unix-like shell, from it do:
pacman -S msys/binutils msys/gcc msys/mingw-w64-cross-crt-git clang64/mingw-w64-clang-x86_64-gmp
This command above will install all needed packages to use GMP. If you need more packages use -Ss option like pacman -Ss clang, this will search for CLang, so -Ss does search and -S installs.
If you need some time later, pacmans -Syu command updates all installed packages, run this command two times, one time updates base system files, second time all other packages (after first time you need to close and open MSYS shell again).
Now you need one tweak, rename two symbols inside library libmingwex.a because of collisions with libucrt.lib library of Visual Studio.
In following two commands I assume that your MSYS installation folder is c:\dev\msys\, you can change to one that you installed to.
c:\bin\msys\usr\bin\objcopy.exe --redefine-sym wcsnlen=wcsnlen_renamed --redefine-sym strnlen=strnlen_renamed c:\bin\msys\opt\x86_64-w64-mingw32\lib\libmingwex.a c:\bin\msys\opt\x86_64-w64-mingw32\lib\libmingwex_renamed.a
(this will create file libmingwex_renamed.a with renamed two symbols out of libmingwex.a library)
Now everything is ready and you can compile your C++ program like following:
cl program.cpp /O2 /GL /EHsc /std:c++latest /Ic:\bin\msys\clang64\include\ c:\bin\msys\clang64\lib\libgmp.a c:\bin\msys\usr\lib\gcc\x86_64-pc-msys\11.3.0\libgcc.a c:\bin\msys\opt\x86_64-w64-mingw32\lib\libmingwex_renamed.a
See that in command above I used 3 libraries libgmp.a and libgcc.a and libmingwex_renamed.a. Also notice that libgcc.a is taked from sub-folder \11.3.0\, it is current version of installed GCC, but when time passes MSYS2 updates GCC to later versions, so this version-subfolder should be changed accordingly.
Third
Install Visual Studio like in First and Second steps.
In this step we will use MPIR, it is a fork of GMP, really good fork more suitable for Windows.
Clone repository:
git clone https://github.com/BrianGladman/mpir --depth=1
Inside folder .\mpir\msvc\vs22\ run:
cmd /c msbuild.bat gc LIB x64 Release
Above command builds Generic version that is suitable for any CPU. After that do
cmd /c msbuild.bat skylake_avx LIB x64 Release
Which builds very optimized version, faster than generic.
Very Important. If second (skylake) builds with failure, then Generic (gc) version can be used but it can be even 5x times slower. If fast Skylake version has failed then better not to use this Third way of compiling GMP, unless you can't do others, or if slow version is enough for you.
This command above should be run as usual from "x64 Native Command Prompt" shell of Visual Studio in Start Menu.
After build is finished GMP (actually MPIR), you can compile your program as:
cl program.cpp /O2 /GL /EHsc /std:c++latest /Ipath_to_mpir_repo\msvc\vs22\lib_mpir_skylake_avx\x64\Release\ path_to_mpir_repo\msvc\vs22\lib_mpir_skylake_avx\x64\Release\mpir.lib
Note that in command above I used \lib_mpir_skylake_avx\ subfolder for optimized AVX version, please use \lib_mpir_gc\ subfolder if only Generic version is available.
Compiling GMP on Windows with VisualStudio might be tricky, however there are already some SO questions, that might help you (depending on your exact use-case):
Building GMP library with Visual Studio?
How to install MPFR and GMP for C++ on visual studio
GMP on visual studio c++
Simple answer is, that there are no sources of GMP compilable directly using VisualStudio as GMP is developed with UNIX in mind.
Summary of your options:
Use GMP version provided in your MinGW distribution
Compile own GMP using MinGW/Cygwin
Use MPIR fork of GMP compilable using VisualStudio
Try to solve all the compilation problems yourself, some hints for older GMP versions are here:
https://cs.nyu.edu/exact/core/gmp/
http://www.blizzhackers.cc/viewtopic.php?t=393933
I faced the same problem in Windows 11 when I needed both gmp and gmpxx for which only the first option works, thanks to #Arty.
The only thing to add is that vcpkg install gmp --triplet=x64-windows-static command should be run in a terminal with admin privilege, otherwise the following error will occur:
file RENAME failed to rename
C:/Users/Desktop/polycut/vcpkg/packages/gmp_x64-windows-static
to
C:/Users/Desktop/polycut/vcpkg/packages/gmp_x64-windows-static_tmp
because: Access is denied.

CMake Cant Find Some Image Libs

Im Trying To Compile Blender 2.7
I was Trying to Generate The Visual Studio 12 ( 2013 ) Project Files
using CMake But The Problem is That I Get An Error
Could NOT find ZLIB (missing: ZLIB_LIBRARY ZLIB_INCLUDE_DIR)
Could NOT find PNG (missing: PNG_LIBRARY PNG_PNG_INCLUDE_DIR)
CMake Warning at CMakeLists.txt:1089 (message):
Using HARDCODED libpng locations
Could NOT find JPEG (missing: JPEG_LIBRARY JPEG_INCLUDE_DIR)
Found Freetype: C:/Users/Alfrek/Desktop/Blender 2.7/blender-2.71/../lib/win64_vc12/freetype/lib/freetype2ST.lib
Could NOT find OpenEXR (missing: _openexr_LIBRARIES OPENEXR_INCLUDE_DIR)
CMake Warning at CMakeLists.txt:1172 (message):
Using HARDCODED OpenEXR locations
Could NOT find TIFF (missing: TIFF_LIBRARY TIFF_INCLUDE_DIR)
CMake Warning at CMakeLists.txt:1191 (message):
Using HARDCODED libtiff locations
Could NOT find Boost
CMake Warning at CMakeLists.txt:1230 (message):
USING HARDCODED boost locations
Could NOT find OpenImageIO (missing: OPENIMAGEIO_LIBRARY OPENIMAGEIO_INCLUDE_DIR)
CMake Error at CMakeLists.txt:1928 (message):
Apple and Windows require pre-compiled libs at:
'C:/Users/Alfrek/Desktop/Blender 2.7/blender-2.71/../lib/win64_vc12'
I got No idea what am I suppose to do
I Have a Windows 7 64 Bit Computer
and Im Using Visual Studio Professional 2013
You downloaded the source files but forgot its dependencies. For each platform blender provides its dependencies in its SVN repo.
This is what you need to do:
Outside of the blender directory create the folder structure "lib/win64_vc12"
cd inside that directory, open your command prompt (assuming you have SVN installed) and type
svn checkout https://svn.blender.org/svnroot/bf-blender/trunk/lib/win64_vc12
bear in mind its a huge repo of about 6.5Gb.
When that is done run configure again in cmake and it should work.
It sounds like you are missing a step before trying to run make full...
You will need to run the install_deps.sh script or print the list of all main dependencies needed to build Blender (--show-deps option) and install them manually.
Please see the official blender wiki for updated development environment requirements --> https://wiki.blender.org/wiki/Building_Blender/Linux/Ubuntu
Automatic dependencies installation The preferred way to install dependencies under Linux is now to use the install_deps.sh script
featured with Blender sources. It currently supports Debian (and
derived), Fedora, Suse and Arch distributions. When using the
install_deps.sh script, you are only required to install the following
dependencies:
git, build-essential
Then, get the sources and run install_deps.sh
cd ~/blender-git
./blender/build_files/build_environment/install_deps.sh

Qt installation error

i got an error when am trying to configure Qt.
Erro :
execute: File or path is not found (nmake)
execute: File or path is not found (nmake)
Cleaning qmake failed, return code -1
// installion files.
InterBase...............no
Sources are in..............E:\xampp\Qt\4.6
Build is done in............E:\xampp\Qt\4.6
Install prefix..............E:\xampp\Qt\4.6
Headers installed to........E:\xampp\Qt\4.6\include
Libraries installed to......E:\xampp\Qt\4.6\lib
Plugins installed to........E:\xampp\Qt\4.6\plugins
Binaries installed to.......E:\xampp\Qt\4.6\bin
Docs installed to...........E:\xampp\Qt\4.6\doc
Data installed to...........E:\xampp\Qt\4.6
Translations installed to...E:\xampp\Qt\4.6\translations
Examples installed to.......E:\xampp\Qt\4.6\examples
Demos installed to..........E:\xampp\Qt\4.6\demos
Creating qmake...
execute: File or path is not found (nmake)
execute: File or path is not found (nmake)
Cleaning qmake failed, return code -1
E:\xampp\Qt\4.6>
If you are trying to build Qt with a Visual Studio enviroment, you have to make sure that nmake and cl are in the PATH.
The easiest way to do that is to simply use the Visual Studio Command Prompt (found e.g. in the start menu).
You need to change your path so that it leads to wherever nmake is.
Try adding the flag "-make nmake" to your configure command.