Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to link compress2, uncompress and compress on 64 bit Windows 7 & Visual Studio 2015 when building openexr? #234

Closed
ghost opened this issue Jun 5, 2017 · 5 comments
Labels
Build A problem with building or installing the library. Question A question or a request for help.

Comments

@ghost
Copy link

ghost commented Jun 5, 2017

On Windows 7 64 bit and Visual Studio 2015, I have built zlib 1.2.11 and now I am trying to build openexr which depends on zlib. But I met with errors as follows:

4>  Generating Code...
4>     Creating library C:/Users/Admin/Downloads/openexr-2.2.0/build/IlmImf/Release/IlmImf-2_2.lib and object C:/Users/Admin/Downloads/openexr-2.2.0/build/IlmImf/Release/IlmImf-2_2.exp
4>ImfDwaCompressor.obj : error LNK2019: unresolved external symbol compress2 referenced in function "private: int __cdecl Imf_2_2::DwaCompressor::compress(char const *,int,class Imath_2_2::Box<class Imath_2_2::Vec2<int> >,char const * &)" (?compress@DwaCompressor@Imf_2_2@@AEAAHPEBDHV?$Box@V?$Vec2@H@Imath_2_2@@@Imath_2_2@@AEAPEBD@Z)
4>ImfDwaCompressor.obj : error LNK2019: unresolved external symbol uncompress referenced in function "private: int __cdecl Imf_2_2::DwaCompressor::uncompress(char const *,int,class Imath_2_2::Box<class Imath_2_2::Vec2<int> >,char const * &)" (?uncompress@DwaCompressor@Imf_2_2@@AEAAHPEBDHV?$Box@V?$Vec2@H@Imath_2_2@@@Imath_2_2@@AEAPEBD@Z)
4>ImfPxr24Compressor.obj : error LNK2001: unresolved external symbol uncompress
4>ImfZip.obj : error LNK2001: unresolved external symbol uncompress
4>ImfPxr24Compressor.obj : error LNK2019: unresolved external symbol compress referenced in function "private: int __cdecl Imf_2_2::Pxr24Compressor::compress(char const *,int,class Imath_2_2::Box<class Imath_2_2::Vec2<int> >,char const * &)" (?compress@Pxr24Compressor@Imf_2_2@@AEAAHPEBDHV?$Box@V?$Vec2@H@Imath_2_2@@@Imath_2_2@@AEAPEBD@Z)
4>ImfZip.obj : error LNK2001: unresolved external symbol compress
4>C:\Users\Admin\Downloads\openexr-2.2.0\build\IlmImf\Release\IlmImf-2_2.dll : fatal error LNK1120: 3 unresolved externals

But the three functions compress2, uncompress and compress are exposed from zlib.lib. I can prove it by dumpbin:

      1    0 00001000 adler32
      2    1 00001010 adler32_combine
      3    2 000010F0 adler32_z
      4    3 000013D0 compress
      5    4 000013F0 compress2
      6    5 000014F0 compressBound
      7    6 00001510 crc32
      8    7 00001520 crc32_combine
      ... ...

How to fix this issue? Was the linker trying to link zlib.lib or zlibstatic.lib which exposes nothing? Can I force openexr to link to zlib.lib?

The cmake command to config zlib is:

cmake
-DCMAKE_INSTALL_PREFIX:STRING=C:/Users/Admin/Downloads/OIIO/external/zlib-1.2.11
-G "Visual Studio 14 2015 Win64" ..

and the cmake command to config openexr is:

cmake
-DILMBASE_PACKAGE_PREFIX:STRING=C:/Users/Admin/Downloads/OIIO/external/ilmbase-2.2.0
-DCMAKE_INSTALL_PREFIX:STRING=C:/Users/Admin/Downloads/OIIO/external/openexr-2.2.0
-DZLIB_LIBRARY:STRING=C:/Users/Admin/Downloads/OIIO/external/zlib-1.2.11/lib -DZLIB_INCLUDE_DIR:STRING=C:/Users/Admin/Downloads/OIIO/external/zlib-1.2.11/include -G "Visual Studio 14 2015 Win64" ..

They look correct and I didn't change anything else. So how to link these 3 functions to openexr (or IlmImf)? Thanks a lot for your help!

@meshula
Copy link
Contributor

meshula commented Jun 5, 2017

I'm wondering if you've build zlib static, and OpenEXR wants zlib dynamic, or vice versa?

@ghost
Copy link
Author

ghost commented Jun 6, 2017

OK, I found out where the problem is. I should use -DZLIB_ROOT="C:\Users\Admin\Downloads\OIIO\external\zlib-1.2.11" to specify the location of zlib, but I was misled by this link to use ZLIB_LIBRARY and ZLIB_INCLUDE_DIR for the same purpose, as you can see in my original thread. So, after correcting the cmake command, I got openexr as desired. To clarify, the correct cmake command is:

cmake -DILMBASE_PACKAGE_PREFIX:STRING=C:/Users/Admin/Downloads/OIIO/external/ilmbase-2.2.0 -DCMAKE_INSTALL_PREFIX:STRING=C:/Users/Admin/Downloads/OIIO/external/openexr-2.2.0 -DZLIB_ROOT="C:\Users\Admin\Downloads\OIIO\external\zlib-1.2.11" -G"Visual Studio 14 2015 Win64" ..

PS: I think nowadays at least 80% information in internet are wrong. Documents of some well-known libraries are still talking about 32 bit. Who is using 32 bit CPU today? I saw everyone use 64 bit OS more than 5 years ago. Sigh...

@meshula
Copy link
Contributor

meshula commented Jun 6, 2017

Yuck!
Well, glad you figured it out!

@ghost
Copy link
Author

ghost commented Jun 9, 2017

I think the ZLIB_LIBRARY variable should be set to a lib file like zlib.lib but I set it to the lib folder. Maybe that caused the problem. Anyway, ZLIB_ROOT saves us a lot of typing.

@cary-ilm cary-ilm added Build A problem with building or installing the library. Question A question or a request for help. labels Jun 13, 2019
@cary-ilm
Copy link
Member

Looking into the OpenEXR issue backlog. This issue seems to be resolved, so closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Build A problem with building or installing the library. Question A question or a request for help.
Projects
None yet
Development

No branches or pull requests

2 participants