AcademySoftwareFoundation / openexr

The OpenEXR project provides the specification and reference implementation of the EXR file format, the professional-grade image storage format of the motion picture industry.
http://www.openexr.com/
BSD 3-Clause "New" or "Revised" License
1.6k stars 606 forks source link

can't build openexr #1374

Open hlu2021 opened 1 year ago

hlu2021 commented 1 year ago

I'm using the command 'cmake ..' to build in windows 10 and get a error message below, It seems that the openexr hasn't been properly installed. Anyone can help recommend what command I should try? Thanks

By not providing "FindImath.cmake" in CMAKE_MODULE_PATH this project has asked CMake to find a package configuration file provided by "Imath", but CMake did not find one.

Could not find a package configuration file provided by "Imath" (requested version 3.1) with any of the following names:

ImathConfig.cmake
imath-config.cmake

Add the installation prefix of "Imath" to CMAKE_PREFIX_PATH or set "Imath_DIR" to a directory containing one of the above files. If "Imath" provides a separate development package or SDK, be sure it has been installed.

Vertexwahn commented 1 year ago

Take a look at the CI instructions to see how OpenEXR is built using CMake.

You can also build with Bazel. Here is an example.

hlu2021 commented 1 year ago

Thank you Vertexwahn for your kind reply. I've installed Bazel and tried 'bazel run //:Demo '. But lots of errors that I don't understand. I also checked the CI instructions, but due to my limited knowledge on code compile, I don't understand how to use the content in the work flow either. Is there a step by step instruction on how to use cmake to build opener? Thanks.

meshula commented 1 year ago

you should be able to do this:

cd myProjectDir
git clone https://github.com/AcademySoftwareFoundation/openexr
mkdir openexr-build
cd openexr-build
cmake ../openexr -DCMAKE_INSTALL_PREFIX=./install

then build the using the generated build system files. You'll want to pick the "INSTALL" target to build. When it's done, the install directory will have the typical bin, lib, include, and so on.

Once you're comfortable with that, then you should think about where you really want to install to, and do the above process again, changing the install prefix as needed.

meshula commented 1 year ago

In general, you shouldn't see the error about Imath, because OpenEXR automatically installs Imath if it can't find it. To diagnose those sorts of problems, we'd need to know more, like what OS you are on, what tool chain you are using, and so on. But I'd definitely try to get an out of the box build going before working on anything like that.

I would also want to verify that you are building a current version of OpenEXR, not something in the OpenEXR 2 series - the "2" series requires a lot more build knowledge and skills than the 3 series.

hlu2021 commented 1 year ago

Hi Meshula, I'm able to build without error after rebuilding the zlib in visual studio. But the generated file only consist of a 'bin' folder, no lib, include folder. Do you have any idea what could be wrong? Thanks

meshula commented 1 year ago

Even though it complains during configuration that Imath wasn't found, it will download it automatically when you build. Our messages should be better, instead of reporting an error, it should report that it couldn't find Imath, and it should then say something like "Imath will be downloaded automatically when you build". But it doesn't say that. Anyway,

I just verified things work here, on a clean windows 2022 machine.

So, maybe try again, in a clean directory?

  1. be sure you are in the x64 VS2022 command shell
  2. clone the repo and configure as above
  3. open the resulting OpenEXR.sln file in vs2022
  4. set the target to one you prefer, such as RelWithDebInfo
  5. right click INSTALL in the solution browser, and pick build

these steps succeeded for me just now.

meshula commented 1 year ago

on second thought, your error messages show a problem with zlib symbols not being found. I do wonder if maybe cmake is finding the wrong zlib on your system somehow?

Could you attach your CMakeCache.txt file please? That might have some clues in it.

hlu2021 commented 1 year ago

Hi Meshula, you are right. After rebuilding the zlib in visual studio, I'm able to build without error. The CMakeCache file after the build is attached above. The problem right now is the generated file only consist of a 'bin' folder, no lib, include folder. Do you have any idea what could be wrong? Thanks

hlu2021 commented 1 year ago

Hi Meshula, thank you very much! I tried your solution above, and it works. The install folder now has bin, include, lib, and share. Thank you so much for your generous help.

meshula commented 1 year ago

Great! Glad it's working for you now. If there's any improvement you can think of for our build instructions that would have made the experience better for you, we'd be happy to modify the instructions.

hlu2021 commented 1 year ago

Hi Meshula, I think the 5 steps you have above works good for me. Also, the Workflow in the link below helps to me identify which error message to ignore and the library I need is clang and zlib. https://github.com/AcademySoftwareFoundation/openexr/actions/runs/4571082241/jobs/8069046804

Besides, since I don't have much experience with library build, I struggled with clang and zlib installation a little bit. I summarized below a full list of what works for me. Hope it can be helpful for others to use openexr in windows.

  1. Install visual studio.
  2. install LLVM-16.0.0-win64.exe for clang
  3. build zlib: -download zlib source code from https://github.com/madler/zlib/releases -using visual studio, open zlibvc.sln from .\zlib-1.2.13\contrib\vstudio\vc14\zlibvc.sln -in the solution browser, right click solution and click build
  4. Add to system path the path for zlib and clang
  5. git clone https://github.com/AcademySoftwareFoundation/openexr using git App
  6. open visual studio, go to tools-Command Line-Developer Command Prompt, and type the command below: cd myProjectDir mkdir openexr-build cd openexr-build cmake ../openexr -DCMAKE_INSTALL_PREFIX=./install
  7. open '..\openexr\openexr-build\OpenEXR.sln' in visual studio 2022
  8. In solution configuration, select Release and x64
  9. right click INSTALL in the solution browser, and click build
hlu2021 commented 1 year ago

Hi Meshula, now It seems that I have built the openexr without error. But I'm not sure how can I use the function in the library. I have two more question regarding using openexr.

  1. How do I test if the library works well? I have very little experience with C, is there an example code for using the openexr libraries
  2. If I want to use the openexr in python, is there any instructions on how to use it in python? Thank you again very much!
meshula commented 1 year ago

I would recommend reading the source code for the various tools in src/bin, or the examples in src/examples.

For python, OpenImageIO might be a good place to explore. It will open more than just OpenEXR files. OpenEXR itself hasn't got an official Python bindings otherwise, although there are unofficial bindings here https://pypi.org/project/OpenEXR/

meshula commented 1 year ago

And thanks for your build notes, much appreciated!

Vertexwahn commented 1 year ago

@hlu2021 I added some notes how to setup it here: https://github.com/Vertexwahn/BazelDemos/tree/main/third_party_libraries/cpp/OpenEXR

mike-frank commented 1 month ago

@meshula @hlu2021

Thanks for refining the build instructions - was having trouble getting a build to work on Windows w/ Visual Studio yesterday, before finally finding your solution.

I'm not sure if it was a struggle because of my unfamiliarity with VS / Cmake (common knowledge?), but I think the outlined steps could be a good addition to the install instructions.