[BUG] depthai-core does not build on Mac OSX Sequoia 15.4.1
Describe the bug
A fresh checkout of depthai-core fails to build on OSX 15.4.1, failing (initially) when attempting to build zlib. I believe that this is because the version of zlib used does not compile when using a C23 compiler (which is the default compiler on this version of OSX).
Once this issue is resolved, the next failure is nholmann/json - it's doing some questionable template stuff that the compiler hard errors on (and you can't force the error to a warning):
.hunter/_Base/cb0ea1f/8c87124/7ad1efd/Install/include/nlohmann/json.hpp:5989:41: error: implicit instantiation of undefined template 'std::char_traits
Bottom line, I don't believe anyone has tried to compile this on a recent version of OSX. :)
Minimal Reproducible Example
- Checkout depthai-core repo on OSX 15.4.1
- Attempt to compile following instructions in README.md
- See zlib error
- If you somehow work around zlib error (I used a custom FindZLib cmake macro), compilation will then fail in nholmann/json.
Expected behavior
depthai-core should compile cleanly on OSX.
@dizzyd
Once this issue [build zlib] is resolved, the next failure is …
What approach(es) did you use to resolve the build zlib stage of this issue?
One underlaying zlib problem is that the luxinos/zlib fork v1.2.11-p2 version has a #if defined(MACOS) || defined(TARGET_OS_MAC) … #define fdopen(fd,mode) NULL statement.
The newer macOS build chain now defines fdopen, so any (not-patched-for-this-issue) zlib prior to 1.3.1 will have current macOS tools build issues.
See related: "Update ZLIB to v1.3.1" https://github.com/cpp-pm/hunter/issues/735#issuecomment-2892485545
@marc-medley - as noted in the bug report, I used a custom FindZLib macro that picked up zlib 1.3.1 from homebrew for exactly the reasons you stated re: fdopen.
If that had been the only issue, I would have been happy with it - but finding that there were also weird template issues with the (quite old) nholmann/json library, I decided that this is probably an issue for maintainers to work through. :) There are a number of unusual forks that Luxonis has picked up as part of the depthai-core dependency tree (fp16, libnop, zlib, etc) that probably need updating.
Hi all, thanks for reporting!
We've been shifting a lot of focus to the v3.x.y version of the library, which we'll be release a beta version of this week.
For the issues above, I wonder if it's possible by pinning down C++ version to C++14/17 in the toolchain file when compiling the library?
@dizzyd
… a number of unusual forks that Luxonis has picked up as part of the depthai-core dependency tree (fp16, libnop, zlib, etc) that probably need updating …
… and, the Hunter dependency ecosystem/repository appears to be getting more stale by the year.
I'm wondering what your viewpoint is relative to "some version which builds reliably with an up-to-date macOS toolchain would be OK (i.e., either 2.30.0 or v3.x.y would be fine)" vs "v2.30.0 needs to be updated for the latest macOS toolchain"?
@moratom
In my use case, I'd like the shortest path to a depthai-core version that builds reliably with an up-to-date macOS toolchain, and that works with our existing OAK cameras.
We've been shifting a lot of focus to the v3.x.y version of the library, which we'll be release a beta version of this week.
Is v3.x.y expected to work with existing OAK cameras (e.g. OAK-D-Lite) without a firmware update?
Which branch will be the basis for the beta version? v3_develop?
As fyi, today I found that v3_develop builds OK on a Raspberry Pi OS (Debian) RPi5. However, the --build step of the same repository snapshot failed with the macOS 15.4.1 / Xcode 16.3 / Apple clang version 17.0.0 (clang-1700.0.13.3) toolchain … so, even v3_develop has some macOS issues to work through as well.
That said, the use of vcpkg for v3.x.y looks to provide significantly more up-to-date depencencies than the previously used Hunter.
@dizzyd As fyi, I did manage to get a successful build on macOS 15.4.1 from the v3_develop branch. See [BUG/v3_develop] macOS Sequoia 15.4.1 depthai-core build failure (w/some resolution approaches) #1333 for details.
@dizzyd Following your first fix for zlib (I replaced the findZLIB.cmake used by Hunter by this one), the only thing remaining to fix the undefined std::char_traits error is to replace the whole json.hpp file linked in the error (.hunter/_Base/cb0ea1f/8c87124/7ad1efd/Install/include/nlohmann/json.hppin your case) by the latest version here https://github.com/nlohmann/json/tree/develop/single_include/nlohmann