Search code examples
cmakehomebrew

The following ICU libraries were not found: -- i18n (required)


I have to build miktex source code. I install source code from github they give me link to build it: https://miktex.org/howto/build-mac.

I follow the steps given in the link. When I run

cmake ../source

I got error:

INFOfribidi libs: /usr/local/Cellar/fribidi/1.0.5/lib/libfribidi.dylib
INFOfribidi incs:
/usr/local/Cellar/fribidi/1.0.5/include/fribidi;/usr/local/Cellar/fribidi/1.0.5/include
-- The following ICU libraries were not found:
--   i18n (required)
--   uc (required)
CMake Error at /usr/local/Cellar/cmake/3.12.2/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
    Failed to find all ICU components (missing: ICU_INCLUDE_DIR ICU_LIBRARY _ICU_REQUIRED_LIBS_FOUND)
Call Stack (most recent call first):  
  /usr/local/Cellar/cmake/3.12.2/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)  
  /usr/local/Cellar/cmake/3.12.2/share/cmake/Modules/FindICU.cmake:317 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  CMakeLists.txt:1032 (find_package)
-- Configuring incomplete, errors occurred! See also "/Users/afnisaeed/Desktop/CMakeFiles/CMakeOutput.log".

Extra information:

echo $CMAKE_PREFIX_PATH
/opt/icu4c:/opt/openssl:/opt/icu4c:/opt/qt:$ {brewprefix}/opt/icu4c:/opt/openssl:/opt/icu4c:/opt/qt:/usr/local/Cellar/qt5/5.7.0/

Solution

  • I know nothing at all about miktex or fribidi so this may not be of any assistance at all, however your build system seems to be having difficulty finding something to do with ICU - whatever that is.

    If you run:

    brew info icu4c
    

    it tells you a whole load of stuff about the package being "keg-only" which means the stuff it provides (headers and libraries) is installed, but not where any other package will find it. Then it gives you the following specific advice:

    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"' >> ~/.bash_profile
      echo 'export PATH="/usr/local/opt/icu4c/sbin:$PATH"' >> ~/.bash_profile
    
    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"
    

    So, I suspect you have not done the last 2 sections, and you need to do something like:

    export LDFLAGS="${LDFLAGS} -L/usr/local/opt/icu4c/lib"
    export CPPFLAGS="${CPPFLAGS} -I/usr/local/opt/icu4c/include"
    export PKG_CONFIG_PATH=/usr/local/opt/icu4c/lib/pkgconfig:"$PKG_CONFIG_PATH"
    

    According to comment by @IamMashed, you may also need to run:

    brew install pkg-config