-
Notifications
You must be signed in to change notification settings - Fork 8
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
Trouble building on macOS (my workarounds and suggestions) #50
Comments
@AlienKevin Thank you so much for this thorough exploration and write up! We will start looking into your suggestions. I know that C++17 is top of mind for us and you've already given us a great blueprint for debugging going forward! |
Thanks for sharing the steps, I have tried the method to build fstalign on my macOS ventura(M2Max), the cmakelist definately is outdated for adding a wrong cmake prefix path for mac users. I can confirm that installing openfst 1.7.9 solved my problem and I succesfully built the fstalign. The other method of changing Catch2 to newer version doesn't work for me, the openfst1.8.2 got lots of error related to std:: namespace problem, which I believe is still an issue of C++ version. |
@Rehanchy did you update the bottle section for ventura? If yes what values did you use, I can't seem to find it. |
I confirm these steps worked for me on my most recent laptop (Apple M3 with OS X 14.5)! Nice! |
This library looks awesome but I had trouble building fstalign on macOS sonoma (the issues likely apply to M1 machines running ventura as well). I will outline the steps I followed to build this library, the issues encountered along the way, and temporary workarounds I developed.
git clone https://github.com/revdotcom/fstalign
mkdir build && cd build
cmake .. -DOPENFST_ROOT="/opt/homebrew/Cellar/openfst/1.8.2" -DDYNAMIC_OPENFST=ON
Issue 1:
The following ICU libraries were not found: uc (required)
Reason: The path to icu4c in CMakeList.txt is not for a brew installation:
list(APPEND CMAKE_PREFIX_PATH "/usr/local/opt/icu4c") # for Mac users
Workaround: Run
export CMAKE_PREFIX_PATH="/opt/homebrew/opt/icu4c"
andexport CPATH="/opt/homebrew/opt/icu4c/include"
beforecmake
make
Issue 2: OpenFST dependency fails to build due to usage of C++17 features
Reason: Like many other macOS users, I manage my dependencies through brew. Unfortunately, brew usually provides only the latest version of a package and the latest OpenFST version is 1.8.2, which uses C++17 features. This library uses C++14 and does not build with C++17. I can't find a straight-forward way to update the CMakeLists.txt to specify a separate C++ version for OpenFST only.
Workaround: Download a old version of brew's openfst formula, uninstall OpenFST 1.8.2 and install the older 1.7.9 version which doesn't require C++17. This requires tweaking the old 1.7.9 ruby formula so it took me a while to figure out. See appendix for detailed steps.
Issue 3: With issue 2 fixed, there's still a remaining issue with the Catch2 dependency.
Reason: Older versions of Catch2 uses some x86 assembly code internally that is not compatabile with ARM. Newer versions updated to support both architectures but the version of Catch2 referenced in this library is too old and does not support ARM.
Workaround: Remove the existing Catch2 submodule and download a newer version. I chose v2.13.8 because it supports ARM and shouldn't cause compatability issues with this library:
cd third-party
rm -rf Catch2
git clone --branch v2.13.8 https://github.com/catchorg/Catch2
Rerun
make
and it should build successfully now.After all workarounds are applied, this library finally builds on macOS! To save future users the same trouble as I went through, I have a few suggestions:
libfst.dylib
in place oflibfst.so
on macOS. (Not sure if this is still an issue on OpenFST 1.8.2)Appendix
Workaround to install an older version of OpenFST
Create a file named
openfst.rb
in the current working directory. Below is theopenfst.rb
script I adapted from the original formula for 1.7.9. Thebottle
section has to be updated to use the new syntax.To uninstall 1.8.2, do:
To install the older 1.7.9 from the formula above, do:
Ignore the
Error: Failed to load cask: openfst.rb
message.Brew will create a
libfst.dylib
file but this library requires alibfst.so
file. You need to create a symbolic link namedlibfst.so
to the dylib file for the compiler to find the binary.After the older version is installed, clean the
CMakeCache.txt
and reruncmake
using the older version:Reference: https://nelson.cloud/how-to-install-older-versions-of-homebrew-packages/
The text was updated successfully, but these errors were encountered: