Ive been looking all night, and I havent been able to find a solution.
Im trying to install the mongodb extension by running sudo /Applications/XAMPP/xamppfiles/bin/pecl install mongodb
but at the end I get this error
fatal error: 'unicode/usprep.h' file not found
#include <unicode/usprep.h>
^~~~~~~~~~~~~~~~~~
1 error generated.
make: *** [src/libmongoc/src/libmongoc/src/mongoc/mongoc-scram.lo]
Error 1
ERROR: `make' failed
I had the same issue. I had icu4c
, developer tools, everything I should have needed installed. It should have worked.. I was banging my head against this baffled at why it wouldn't compile.
The issue was this: It was trying to use the icu4c
files located in the XAMPP directory (/Applications/XAMPP/xamppfiles/bin
). This is what shipped with XAMPP and NOT what you just installed (or had installed via brew install icu4c
). It was using the wrong binaries to compile!
You can check where it's pulling from by doing: which icuinfo
It should be something like /usr/local/opt/icu4c/bin/icuinfo
(path may vary, I am on MacOS Catalina and installed with homebrew) and NOT /Applications/XAMPP/xamppfiles/bin
.
Most of us have modified our $PATH
to include the XAMPP bin directory and since icu4c is located at /usr/local/opt/icu4c/bin
and /usr/local/opt/icu4c/sbin
, there is no knowledge of its existence. Those 2 specific icu4c
paths are not in your systems path of locations to search for files in. So either A) it can't find it, or B) it finds the one in the XAMPP bin directory.
Since we basically have icu4c
installed in 2 directories, we need to ensure the one we want is FIRST in our $PATH
and BEFORE XAMPP!
You should know how to modify your $PATH. I use iTerm and zsh (oh-my-zsh) just for reference.
I also added the LDFLAGS
, CPPFLAGS
, and PKG_CONFIG_PATH
values as was recommended after it successfully compiled.
Here is a snip from my .zshrc
file:
# My cleaner way of organizing my paths
BIN=$HOME/bin
LOCAL_BIN=/usr/local/bin
HOMEBREW=/usr/local/sbin
COMPOSER=$HOME/.composer/vendor/bin
XAMPP=/Applications/XAMPP/bin
ICU4C_BIN=/usr/local/opt/icu4c/bin
ICU4C_SBIN=/usr/local/opt/icu4c/sbin
export PATH=$HOMEBREW:$COMPOSER:$ICU4C_BIN:$ICU4C_SBIN:$XAMPP:$BIN:$LOCAL_BIN:$PATH
export LDFLAGS="-L/usr/local/opt/icu4c/lib"
export CPPFLAGS="-I/usr/local/opt/icu4c/include"
export PKG_CONFIG_PATH="/usr/local/opt/icu4c/lib/pkgconfig"
Obviously you can ignore the $HOMEBREW
, $COMPOSER
, etc.. and apply as needed. I just separate them out to have a clean and easy to understand $PATH. Honestly, I really recommend organizing and separating your paths like I did above. It helps out a lot!