NanoMichael / MicroTeX

A dynamic, cross-platform, and embeddable LaTeX rendering library
MIT License
403 stars 67 forks source link

'path' is unavailable: introduced in macOS 10.15 #109

Closed PikachuHy closed 2 years ago

PikachuHy commented 2 years ago

This feature https://github.com/NanoMichael/cLaTeXMath/pull/99 use std::filesystem, while std::filesystem is not available under macOS 10.15.

my version macOS Mojave 10.14.6

due to this limitation, we need to add compatible code.

when std::filesystem is not available, we can fallback to boost::filesytem.

NanoMichael commented 2 years ago

What version of gcc/clang do you use? I've noticed that although std::filesystem is supported by c++17, we also need to link to stdc++fs when gcc version is under 9.1, and it is more complicated when using clang:

Prior to LLVM 9.0, libc++ provides the implementation of the filesystem library in a separate static library. Users of <filesystem> and <experimental/filesystem> are required to link -lc++fs. Prior to libc++ 7.0, users of <experimental/filesystem> were required to link libc++experimental.

Starting with LLVM 9.0, support for <filesystem> is provided in the main library and nothing special is required to use <filesystem>.

In a word, C++ is sucks (actually I don't like C++ at all :sweat_smile: )... So, maybe the best solution is to upgrade your compiler to the version that fully supports std::filesystem.

sp1ritCS commented 2 years ago

I've noticed that although std::filesystem is supported by c++17, we also need to link to stdc++fs when gcc version is under 9.1

yeah, I've noticed that aswell, when playing around with packaging tinytex/unimath (https://build.opensuse.org/package/show/home:sp1rit:testing:notekit/tinytex)

and for Leap <= 15.4 / SLE 15 <= SP4 and RHEL (CentOS 8) I need to

%if 0%{?sle_version} && 0%{?sle_version} <= 150400 || 0%{?rhel}
sed "/tinytex_lib = library/adependencies: cpp.find_library('stdc++fs')," -i lib/meson.build
sed "s|#include <filesystem>|#include <experimental/filesystem>|" -i lib/otf/fontsense.cpp
sed "s/namespace fs = std::filesystem;/namespace fs = std::experimental::filesystem;/" -i lib/otf/fontsense.cpp
%endif

because they ship to old of an compiler.

The meson build manifest has had a workaround (that at least adds stdc++fs for gcc <= 9.1) for this in the current master. I didn't re-add that because I thought this to be irrelevant due to tinytex only supporting c++17.

PikachuHy commented 2 years ago

I add some code to handle the problem. This change only affects macOS 10.14 or lower.

What version of gcc/clang do you use?

apple clang 11

➜  ~ clang -v
Apple clang version 11.0.0 (clang-1100.0.33.12)
Target: x86_64-apple-darwin18.7.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

maybe the best solution is to upgrade your compiler to the version that fully supports std::filesystem.

For data backup, I will upgrade my MacOS version after June. 😢

NanoMichael commented 2 years ago

closed by #110