最新消息:yaf表单扩展中新增加了浮点数、日期和集合的校验。php yaf框架扩展实践三——表单

mac npm安装bcrypt失败ld: library not found for -lgcc_s.10.5

编程开发 971浏览 1评论

在mac下面用npm安装bcrypt这个库的时候提示失败,失败信息如下:

$ sudo npm install bcrypt

> fsevents@0.3.8 install /Users/chenjiebin/Sites/meiqu/meiquapi/node_modules/fsevents
> node-gyp rebuild

  SOLINK_MODULE(target) Release/.node
ld: library not found for -lgcc_s.10.5
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [Release/.node] Error 1
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:276:23)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:784:12)
gyp ERR! System Darwin 14.5.0
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/chenjiebin/Sites/meiqu/meiquapi/node_modules/fsevents
gyp ERR! node -v v0.10.4
gyp ERR! node-gyp -v v3.3.1
gyp ERR! not ok 
npm WARN install:fsevents@0.3.8 fsevents@0.3.8 install: `node-gyp rebuild`
npm WARN install:fsevents@0.3.8 Exit status 1

> bcrypt@0.8.0 install /Users/chenjiebin/Sites/meiqu/meiquapi/node_modules/bcrypt
> node-gyp rebuild

  CXX(target) Release/obj.target/bcrypt_lib/src/blowfish.o
  CXX(target) Release/obj.target/bcrypt_lib/src/bcrypt.o
  CXX(target) Release/obj.target/bcrypt_lib/src/bcrypt_node.o
  SOLINK_MODULE(target) Release/bcrypt_lib.node
ld: library not found for -lgcc_s.10.5
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [Release/bcrypt_lib.node] Error 1
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:276:23)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:784:12)
gyp ERR! System Darwin 14.5.0
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/chenjiebin/Sites/meiqu/meiquapi/node_modules/bcrypt
gyp ERR! node -v v0.10.4
gyp ERR! node-gyp -v v3.3.1
gyp ERR! not ok 
npm WARN meiqu@0.1.0 No repository field.
npm WARN meiqu@0.1.0 No license field.
npm ERR! Darwin 14.5.0
npm ERR! argv "node" "/usr/local/bin/npm" "install" "bcrypt"
npm ERR! node v0.10.4
npm ERR! npm  v3.8.6
npm ERR! code ELIFECYCLE

npm ERR! bcrypt@0.8.0 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the bcrypt@0.8.0 install script 'node-gyp rebuild'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the bcrypt package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs bcrypt
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls bcrypt
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/chenjiebin/Sites/meiqu/meiquapi/npm-debug.log

从信息来看是重新构建node-gyp的时候报出了错误,仔细观察报错信息,后来注意到这行:

ld: library not found for -lgcc_s.10.5

这种信息一般都是指库没有找到,网上搜索相关信息都和xcode有关。印象里前一段时间是可以的,也没这个错误。后来想到会不会是前一段时间升级了xcode导致的。

于是尝试在电脑上搜索libgcc_s这个相关的库:

$ sudo find /  -name '*libgcc_s*'
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/lib/libgcc_s.1.dylib
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/lib/libgcc_s.1.dylib
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/lib/libgcc_s.10.4.dylib
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/lib/libgcc_s.10.5.dylib
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/lib/libgcc_s.1.dylib
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/lib/libgcc_s.10.4.dylib
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/lib/libgcc_s.10.5.dylib
find: /dev/fd/3: Not a directory
find: /dev/fd/4: Not a directory
/usr/lib/libgcc_s.1.dylib
/usr/lib/libgcc_s.10.4.tbd
/usr/lib/libgcc_s.10.5.tbd

发现电脑中存在这样的库:

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/lib/libgcc_s.10.5.dylib

猜测应该是这个库,于是尝试在/usr/local/lib/目录做了个软链接到这个库

$ cd /usr/local/lib/
$ ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/lib/libgcc_s.10.5.dylib libgcc_s.10.5.dylib

再次尝试安装bcrypt就顺利通过了。估计是上次升级xcode的时候库的位置被做了调整,导致npm找不到了。

转载请注明:快乐编程 » mac npm安装bcrypt失败ld: library not found for -lgcc_s.10.5

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

网友最新评论 (1)

  1. 非常感谢,我也是遇到同样的问题,按你的方式解决了
    daniel8个月前 (09-18)回复