openexr: ZLIB_LIBRARY ZLIB_INCLUDE_DIR being ignored (LNK2019 errors) in OpenEXR\IlmImf\IlmImf.vcxproj
In windows 10 x64; using VS2017; using cmake 3.13.14 and a powershell script.
I have multiple LNK2019 error, despite a correct configuration:
ImfDwaCompressor.obj : error LNK2019: unresolved external symbol compress2 referenced in function "private: int __cdecl
Imf_2_3::DwaCompressor::compress(char const *,int,class Imath_2_3::Box<class Imath_2_3::Vec2<int> >,char const * &)" (
?compress@DwaCompressor@Imf_2_3@@AEAAHPEBDHV?$Box@V?$Vec2@H@Imath_2_3@@@Imath_2_3@@AEAPEBD@Z) [I:\lib\master-openexr\bu
ild\OpenEXR\IlmImf\IlmImf.vcxproj]
ImfDwaCompressor.obj : error LNK2019: unresolved external symbol compressBound referenced in function "private: int __c
decl Imf_2_3::DwaCompressor::compress(char const *,int,class Imath_2_3::Box<class Imath_2_3::Vec2<int> >,char const * &
)" (?compress@DwaCompressor@Imf_2_3@@AEAAHPEBDHV?$Box@V?$Vec2@H@Imath_2_3@@@Imath_2_3@@AEAPEBD@Z) [I:\lib\master-openex
r\build\OpenEXR\IlmImf\IlmImf.vcxproj]
ImfDwaCompressor.obj : error LNK2019: unresolved external symbol uncompress referenced in function "private: int __cdec
l Imf_2_3::DwaCompressor::uncompress(char const *,int,class Imath_2_3::Box<class Imath_2_3::Vec2<int> >,char const * &)
" (?uncompress@DwaCompressor@Imf_2_3@@AEAAHPEBDHV?$Box@V?$Vec2@H@Imath_2_3@@@Imath_2_3@@AEAPEBD@Z) [I:\lib\master-opene
xr\build\OpenEXR\IlmImf\IlmImf.vcxproj]
ImfPxr24Compressor.obj : error LNK2001: unresolved external symbol uncompress [I:\lib\master-openexr\build\OpenEXR\IlmI
mf\IlmImf.vcxproj]
ImfZip.obj : error LNK2001: unresolved external symbol uncompress [I:\lib\master-openexr\build\OpenEXR\IlmImf\IlmImf.vc
xproj]
ImfPxr24Compressor.obj : error LNK2019: unresolved external symbol compress referenced in function "private: int __cdec
l Imf_2_3::Pxr24Compressor::compress(char const *,int,class Imath_2_3::Box<class Imath_2_3::Vec2<int> >,char const * &)
" (?compress@Pxr24Compressor@Imf_2_3@@AEAAHPEBDHV?$Box@V?$Vec2@H@Imath_2_3@@@Imath_2_3@@AEAPEBD@Z) [I:\lib\master-opene
xr\build\OpenEXR\IlmImf\IlmImf.vcxproj]
ImfZip.obj : error LNK2001: unresolved external symbol compress [I:\lib\master-openexr\build\OpenEXR\IlmImf\IlmImf.vcxp
roj]
I:\lib\master-openexr\build\OpenEXR\IlmImf\Release\IlmImf-2_3.dll : fatal error LNK1120: 4 unresolved externals [I:\lib
\master-openexr\build\OpenEXR\IlmImf\IlmImf.vcxproj]
Repro: using zlib 1.2.11, compiled in Win64 at I:\lib\zlib
I configure and build openexr with this script:
$target = "Visual Studio 15 2017 Win64"
$zlib_prefix = "I:\lib\zlib"
function configure {
cmake.exe -G $target -T v141, host=x64 -j8 `
-DZLIB_LIBRARY="${zlib_prefix}\lib" -DZLIB_INCLUDE_DIR="${zlib_prefix}\include" `
-DOPENEXR_BUILD_PYTHON_LIBS=0 -DCMAKE_INSTALL_PREFIX="I:\lib\openexr" `
..
}
function build {
"build openexr debug"
MSBuild.exe OpenEXR.sln /verbosity:m /m
"build openexr release"
MSBuild.exe OpenEXR.sln /p:Configuration=Release /verbosity:m /m
}
function install {
"install openexr debug"
MSBuild.exe INSTALL.vcxproj /verbosity:m /m
"install openexr release"
MSBuild.exe INSTALL.vcxproj /p:Configuration=Release /verbosity:m /m
}
if (!(test-path build)) {
New-Item -ItemType Directory build
}
Set-Location build
configure
build
#install
Set-Location ..
Proof: hand-edit IlmImf.vcxproj to use the zlib.lib and zlibd.lib provided works.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 17 (10 by maintainers)
Okay, I went through all the documentation I could find, and the implementation, and compared a bunch of projects on github, some of which do indeed use ZLIB_LIBRARY as an input.
quick summary
details:
https://cmake.org/cmake/help/latest/module/FindZLIB.html
OpenExr looks for ZLIB_INCLUDE_DIR in OpenEXR/CMakeLists.txt, but according to the FindZLIB documentation, it should be looking for ZLIB_INCLUDE_DIRS.
So this is an error in OpenEXR’s cmake scripts.
According to the documentation, using ZLIB_ROOT should be sufficient to set ZLIB_INCLUDE_DIRS and ZLIB_LIBRARIES. Nonetheless, since you only had to edit the vcxproj to add zlib references, setting -DZLIB_LIBRARIES in your script instead of ZLIB_LIBRARY should solve your problem.
I understand that other projects are successfully using ZLIB_LIBRARY, but the implementation itself
https://github.com/Kitware/CMake/blob/master/Modules/FindZLIB.cmake
specifies ZLIB_LIBRARY as an input to FindZLIB, used to set ZLIB_LIBRARIES.
As an interesting point in comparison, conan’s FindZlib script was updated to use ZLIB_LIBRARIES only, which broke some of their dependent packages, so they had to add ZLIB_LIBRARY back in as an exposed variable. https://github.com/conan-community/community/issues/153 They too preferred to stick to documented outputs.
Yes. I downloaded the sources from master the 14th of april.