前天mac用brew安裝NodeJs時候 ,把icu4c這個目錄中的lib/libicui18n.61.dylib搞丟了,nodeJs需要的可能是libicui18n.64.dylib這個版本,但是安裝是時候把PHP依賴的libicui18n.61.dylib丟了,是刪除了還是升級了,不知道,反正是沒有了。在我運行PHP的包工具composer時候,運行命令:composer install,出現下面錯誤:
dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.61.dylib
Referenced from: /usr/local/opt/[email protected]/bin/php
Reason: image not found
Abort trap: 6
解決方法:
1,下載libicui18n.61.dylib 這個包,地址:https://ssl.icu-project.org/files/icu4c/
注意一定要是icu4c-61_1-src.tgz 這個,不要下zip的,zip是針對win系統的,會報錯。如下:
localhost:Downloads fangliang$ ./icu/source/configure
-bash: ./icu/source/configure: /bin/sh^M: bad interpreter: No such file or directory
上面這個問題也可以解決:
先在控制檯cd到報錯的目錄
vi configure
:set ff ?
如果出現fileforma=dos那麼就基本可以確定是這個問題了。
:set fileformat=unix
:wq
2, 下載到機器什麼地方都可以,解壓tar -xzvf icu4c-61_1-src.tgz
1,配置,編譯,安裝。如下:
cd ./source
./configure
make
make install
在configure時候可能出現下面的錯誤:
configure: error: in `/Users/fangliang/Downloads/icu':
configure: error: C compiler cannot create executables
See `config.log' for more details
3,查看config.log,可能會看到這樣的錯誤:
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
configure:2971: $? = 1
configure:2960: clang -v >&5
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
configure:2971: $? = 1
configure:2960: clang -V >&5
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
configure:2971: $? = 1
configure:2960: clang -qversion >&5
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
configure:2971: $? = 1
configure:2991: checking whether the C compiler works
configure:3013: clang conftest.c >&5
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
4,證明xcrun沒有安裝。在終端執行xcrun,安裝:
xcode-select --install
5,安裝成功之後。
make 成功
make install 成功
6,驗證PHP
PHP --version 可用
composer install 可用