octobanana/peaclock

Issues with icu4c on Mac

ivan-andrei-blazic opened this issue · 5 comments

I installed all the pre-requisites and got the following with icu4c:

icu4c is keg-only, which means it was not symlinked into /usr/local,
because macOS provides libicucore.dylib (but nothing else).
If you need to have icu4c first in your PATH run:
echo 'export PATH="/usr/local/opt/icu4c/bin:$PATH"' >> ~/.zshrc
echo 'export PATH="/usr/local/opt/icu4c/sbin:$PATH"' >> ~/.zshrc
For compilers to find icu4c you may need to set:
export LDFLAGS="-L/usr/local/opt/icu4c/lib"
export CPPFLAGS="-I/usr/local/opt/icu4c/include"
For pkg-config to find icu4c you may need to set:
export PKG_CONFIG_PATH="/usr/local/opt/icu4c/lib/pkgconfig"

I proceeded to go through with the install and got the following error
Build type: release -- Building peaclock 0.4.3 in release mode: System: Darwin-19.5.0 CXX compiler: GNU 10.2.0 -- Configuring done -- Generating done -- Build files have been written to: /Users/ivan.blazic/workspace/peaclock/build/release [ 16%] Building CXX object CMakeFiles/peaclock.dir/src/ob/readline.cc.o [ 33%] Building CXX object CMakeFiles/peaclock.dir/src/main.cc.o In file included from /Users/ivan.blazic/workspace/peaclock/./src/ob/readline.hh:4, from /Users/ivan.blazic/workspace/peaclock/src/ob/readline.cc:1: /Users/ivan.blazic/workspace/peaclock/./src/ob/text.hh:6:10: fatal error: unicode/coll.h: No such file or directory 6 | #include <unicode/coll.h> | ^~~~~~~~~~~~~~~~ compilation terminated. make[2]: *** [CMakeFiles/peaclock.dir/src/ob/readline.cc.o] Error 1 make[2]: *** Waiting for unfinished jobs.... In file included from /Users/ivan.blazic/workspace/peaclock/./src/ob/rect.hh:5, from /Users/ivan.blazic/workspace/peaclock/./src/peaclock/peaclock.hh:5, from /Users/ivan.blazic/workspace/peaclock/src/peaclock/tui.hh:4, from /Users/ivan.blazic/workspace/peaclock/src/main.cc:10: /Users/ivan.blazic/workspace/peaclock/./src/ob/text.hh:6:10: fatal error: unicode/coll.h: No such file or directory 6 | #include <unicode/coll.h> | ^~~~~~~~~~~~~~~~ compilation terminated. make[2]: *** [CMakeFiles/peaclock.dir/src/main.cc.o] Error 1 make[1]: *** [CMakeFiles/peaclock.dir/all] Error 2 make: *** [all] Error 2

I can't seem to resolve it as I can't brew link icu4c even if I force it, and adding it to the PATH does not seem to work either.

Are there any updates concerning this issue?

Try adding:

link_directories("/usr/local/opt/icu4c/lib")
include_directories("/usr/local/opt/icu4c/include")

to CMakeLists.txt after the cmake_minimum_required line. Make sure the paths match the values specified in the caveats of brew info icu4c and execute the build script as specified in the readme for macOS. The path might be different for an M1 Mac, so watch out for that.

Also, to dodge another Mac-specific problem, set the locale by exporting LC_ALL=C (or an appropriate value) before running.

This worked for me on M1 Mac (without having to edit CMakeLists.txt)

./RUNME.sh build -- -DCMAKE_CXX_COMPILER='/opt/homebrew/bin/g++-11' -DCMAKE_CXX_FLAGS='-I/opt/homebrew/opt/icu4c/include'

As @rumbletumjum mentioned, you need to run LC_ALL=C before running the binary or else you will get following error:
locale::facet::_S_create_c_locale name not valid.

Thank you @rumbletumjum and @poetaman! Here is what I did to make it work on Mac M1

  1. Install gcc and icu4c.
brew install gcc
brew install icu4c
  1. Add the following lines in CMakeLists.txt after the cmake_minimum_required line.
link_directories("/usr/local/opt/icu4c/lib")
include_directories("/usr/local/opt/icu4c/include")
  1. Build
./RUNME.sh build -- -DCMAKE_CXX_COMPILER='/opt/homebrew/Cellar/gcc/13.1.0/bin/g++-13'
  1. Install
./RUNME.sh install
  1. Run peaclock
LC_ALL=C peaclock

I have everything installed and build process goes well until I get an error ld: library 'icuuc' not found. I have the path to the icu4c lib and include correctly specified.

EDIT: It worked! Should have read the instructions properly. I had copied the link and include calls at the end of the file.