OpenImageIO icon indicating copy to clipboard operation
OpenImageIO copied to clipboard

[BUG] Python bindings will not compile under Windows

Open nedwilson opened this issue 4 years ago • 1 comments

Describe the bug When using Microsoft's "vcpkg" package manager to build and install OpenImageIO with Python bindings, a CMake error is produced, and the product will not build.

To Reproduce Steps to reproduce the behavior:

  1. Install Microsoft's package manager: git clone https://github.com/microsoft/vcpkg
  2. Bootstrap the vcpkg source clone: .\vcpkg\bootstrap-vcpkg.bat
  3. Install OpenImageIO with python bindings: .\vcpkg.exe install openimageio[pybind11]
  4. Then THIS happens (reproduce the exact error message if you can) Error: building package openimageio:x86-windows failed with: BUILD_FAILED

Expected behavior Package builds and installs successfully.

Evidence The PowerShell window indicates that additional error messages are available: See logs for more information: C:\Dev\vcpkg\buildtrees\openimageio\install-x86-windows-debug-out.log Examining this log reveals the following error: C:\Dev\vcpkg\buildtrees\openimageio\src\a25d056cb0-36fa00c6d2.clean\src\python\py_oiio.cpp(77): error C3861: 'ssize_t': identifier not found If we are going to mess with the source and then attempt to reinstall, we should use the editable flag, like so: .\vcpkg.exe install openimageio[pybind11] --editable Reexamining the build log for the error points us to the following source file: C:\Dev\vcpkg\buildtrees\openimageio\src\a25d056cb0-36fa00c6d2\src\python\py_oiio.cpp Open this file, and insert the following code, starting at line 8: #if defined(_MSC_VER) #include <BaseTsd.h> typedef SSIZE_T ssize_t; #endif Save the file, and re-run the install: .\vcpkg.exe install openimageio[pybind11] --editable The package will now build and install without error.

It should be noted that I am by no means a qualified Windows developer - I'm pretty sure that ssize_t is a POSIX type, which is why that hack worked, but I'm not comfortable doing a pull request and making changes. However, I hope this bug report makes it easier for someone who is qualified to patch the code.

Platform information:

  • OIIO branch/version: master/2.3.7.2
  • OS: Microsoft Windows 10 Professional - Version 20H2 (OS Build 19042.1288)
  • C++ compiler: cl.exe - Microsoft C/C++ Optimizing Compiler Version 19.29.30136 for x86
  • Any non-default build flags when you build OIIO:

nedwilson avatar Oct 15 '21 17:10 nedwilson

To fix that I modify header with:

using ssize_t = Py_ssize_t;

soufianekhiat avatar Dec 06 '21 18:12 soufianekhiat

Is this still a problem?

lgritz avatar Sep 27 '23 06:09 lgritz

I think this has long been fixed. Closing.

lgritz avatar Feb 14 '24 05:02 lgritz