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

Apple build failed with json/single_include/nlohmann/json.hpp:4384:57: 'path' is unavailable #3097

Closed
1 task done
tongyuze opened this issue Oct 19, 2021 · 12 comments · Fixed by #3101
Closed
1 task done

Comments

@tongyuze
Copy link

tongyuze commented Oct 19, 2021

What is the issue you have?

I just updated the json.hpp from version 3.9.1 to 3.10.4. And the newest version failed the Mac/iOS build with the error:
"json/single_include/nlohmann/json.hpp:4384:57: 'path' is unavailable"
This happened during compilation.

Please describe the steps to reproduce the issue.

Can you provide a small but working code example?

What is the expected behavior?

Build should succeed.

And what is the actual behavior instead?

Build failed with the above error.

Which compiler and operating system are you using?

  • Compiler: com.apple.compilers.llvm.clang.1_0.compiler
  • Operating system: macOS 11.6

Which version of the library did you use?

  • latest release version 3.10.4

If you experience a compilation error: can you compile and run the unit tests?

@tongyuze
Copy link
Author

I think that's because our deployment target is 10.11 which doesn't introduce "std::filesystem::path"

@nlohmann
Copy link
Owner

Seems to be related to #3090.

@jmelas
Copy link

jmelas commented Oct 21, 2021

I have the same problem. My macOS deployment target is 10.12 so std::filesystem is unavailable.
So we need something like this for filesystem on mac:
#if (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15) && defined(JSON_HAS_CPP_17)
instead of simply
#ifdef JSON_HAS_CPP_17

@tongyuze
Copy link
Author

I have the same problem. My macOS deployment target is 10.12 so std::filesystem is unavailable. So we need something like this for filesystem on mac: #if (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15) && defined(JSON_HAS_CPP_17) instead of simply #ifdef JSON_HAS_CPP_17

And also the iOS version should be >= 13.0.

@nlohmann
Copy link
Owner

I have the same problem. My macOS deployment target is 10.12 so std::filesystem is unavailable. So we need something like this for filesystem on mac: #if (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15) && defined(JSON_HAS_CPP_17) instead of simply #ifdef JSON_HAS_CPP_17

And also the iOS version should be >= 13.0.

Thanks for the input! I will see to add the preprocessor macros. What would be the macro to test the iOS version?

@tongyuze
Copy link
Author

tongyuze commented Oct 21, 2021

I have the same problem. My macOS deployment target is 10.12 so std::filesystem is unavailable. So we need something like this for filesystem on mac: #if (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15) && defined(JSON_HAS_CPP_17) instead of simply #ifdef JSON_HAS_CPP_17

And also the iOS version should be >= 13.0.

Thanks for the input! I will see to add the preprocessor macros. What would be the macro to test the iOS version?

For ios, it should be #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 130000
For mac, it should be if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101500

@gregmarr
Copy link
Contributor

gregmarr commented Oct 21, 2021

It would be better to see if the feature test macros that are in PR now pick it up properly.
https://github.com/nlohmann/json/tree/issue3090

@nlohmann
Copy link
Owner

nlohmann commented Oct 21, 2021

It would be better to see if the feature test macros that are in PR now pick it up properly.
https://github.com/nlohmann/json/tree/issue3090

If I understood the documentation correctly, then on macOS, the headers may be there, but the needed library is not present on earlier versions.

In any case, it would be great to add an example for such a macOS/iOS build to the CI. @tongyuze can you provide an example?

@gregmarr
Copy link
Contributor

If I understood the documentation correctly, then on macOS, the headers may be there, but the needed library is not present on earlier versions.

Sigh.

nlohmann added a commit that referenced this issue Oct 21, 2021
@jmelas
Copy link

jmelas commented Oct 22, 2021

Another idea is to make std::filesystem support optional with something like
#define JSON_NO_STD_FILESYSTEM

@nlohmann
Copy link
Owner

PR #3101 does this: if you define JSON_HAS_FILESYSTEM or JSON_HAS_EXPERIMENTAL_FILESYSTEM, then you can override the auto-detection.

nlohmann added a commit that referenced this issue Dec 29, 2021
* ⚗️ add C++17 copies of the test binaries
* ⚗️ use proper header for filesystem
* 🚨 fix warnings
* ⚗️ do not use too old compilers with C++17
* ✅ add test
* 🔨 add more constraints #3097
* ⚗️ use fix from #3101 (comment)
* ⚗️ use fix from https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90050
* 👷 use published CI image
@nlohmann
Copy link
Owner

Fixed with #3090.

@nlohmann nlohmann linked a pull request Dec 29, 2021 that will close this issue
@nlohmann nlohmann added this to the Release 3.10.5 milestone Dec 29, 2021
@nlohmann nlohmann self-assigned this Dec 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants