openvdb icon indicating copy to clipboard operation
openvdb copied to clipboard

[BUILD] Python module failure to build on MSVC 2022 with numpy: ssize_t: undeclared identifier

Open Luke-Skycrawler opened this issue 2 years ago • 2 comments

Environment

Operating System: Windows 11 Version / Commit SHA: 11.0.0 CMake Version: 3.21 Compiler: msvc 2022

Describe the problem

When I build the python module with numpy support, the MSVC compiler will complain about the ssize_t used in pyGrid.h

To Reproduce

Steps to reproduce the behavior:

  1. Use the 11.0.0 Release
  2. install all the dependencies using vcpkg, basically following README.md. Toggle on OPENVDB_BUILD_WITH_PYTHON_MODULE and USE_NUMPY. (I did it in CMake GUI)
  3. See error
cmake --build . --parallel 4 --config Release --target install
MSBuild version 17.7.2+d6990bcfa for .NET Framework

  openvdb_shared.vcxproj -> C:\repo\openvdb-11.0.0\openvdb-11.0.0\build\openvdb\openvdb\Release\openvdb.dll
  pyFloatGrid.cc
  pyGridBase.cc
  pyIntGrid.cc
  pyMetadata.cc
  pyOpenVDBModule.cc
  pyPointGrid.cc
  pyTransform.cc
  pyVec3Grid.cc
C:\repo\openvdb-11.0.0\openvdb-11.0.0\openvdb\openvdb\python\pyGrid.h(325,33): error C2065: 'ssize_t': undeclared ident
ifier (compiling source file C:\repo\openvdb-11.0.0\openvdb-11.0.0\openvdb\openvdb\python\pyOpenVDBModule.cc) [C:\repo\
openvdb-11.0.0\openvdb-11.0.0\build\openvdb\openvdb\python\pyopenvdb.vcxproj]
C:\repo\openvdb-11.0.0\openvdb-11.0.0\openvdb\openvdb\python\pyGrid.h(325,26): error C2923: 'std::vector': 'ssize_t' is
 not a valid template type argument for parameter '_Ty' (compiling source file C:\repo\openvdb-11.0.0\openvdb-11.0.0\op
envdb\openvdb\python\pyOpenVDBModule.cc) [C:\repo\openvdb-11.0.0\openvdb-11.0.0\build\openvdb\openvdb\python\pyopenvdb.
vcxproj]

I managed to get it fixed according to here https://github.com/eridur-de/mightyscape-1.2/issues/131. The fix was to replace all ssize_t with size_t in pyGrid.h.

Luke-Skycrawler avatar Dec 07 '23 07:12 Luke-Skycrawler

I also have this issue, and I'm reluctant to start editing code directly due to the time and technical debt that builds up most of the time. Let me know if you need additional information from my perspective.

Isn't this just an OS flag that flips between type definitions? Or am I oversimplifying things?

I ended up going to WSL Ubuntu 22.04 and working there (tried with the Ubuntu 20.04 I had installed, but that didn't work due to versions of libraries being too low on that older OS). There's a list of things that need to be installed and setup (and half my time is focused on setting up oh-my-zsh, just because ;)) but it works in the end. Working inasmuch as I can import and generate the hello world sphere without error. Not sure on functionality from that point onwards.

@Luke-Skycrawler , let me know if you need further info on the WSL direction.

nranthony avatar Dec 12 '23 19:12 nranthony

I believe the following PR may solve this issue https://github.com/AcademySoftwareFoundation/openvdb/pull/1706

Idclip avatar Jan 05 '24 03:01 Idclip