请教,mac安装mysql-libmysqlclient失败。
发布于 12 年前 作者 mackjoner 11507 次浏览 最后一次编辑是 8 年前

我已经和作者联系了多次,问题讨论

我咨询了一些使用Mac的开发人员,说是我的Xcode是最新版本,然后我安装了Xcode4.1,安装依旧失败,后来使用GCC-10.7-v2.pkg这个软件包,安装还是失败。
OS: Mac OS X Lion 10.7.3
gcc: llvm 4.2
g++: llvm 4.2
node: 0.6.17
npm: 1.1.21
mysql: 5.5.21
node是用git clone源码安装的,mysql是dmg安装包安装的,已经配置环境变量。

localhost:nodejs yangzhaojie$ CXX=/usr/bin/gcc npm install mysql-libmysqlclient
npm http GET https://registry.npmjs.org/mysql-libmysqlclient
npm http 200 https://registry.npmjs.org/mysql-libmysqlclient
npm http GET https://registry.npmjs.org/mysql-libmysqlclient/-/mysql-libmysqlclient-1.3.2.tgz
npm http 200 https://registry.npmjs.org/mysql-libmysqlclient/-/mysql-libmysqlclient-1.3.2.tgz

> mysql-libmysqlclient[@1](/user/1).3.2 install /Users/yangzhaojie/tech/nodejs/node_modules/mysql-libmysqlclient
> node-gyp rebuild

info it worked if it ends with ok 
spawn python [ '/Users/yangzhaojie/.node-gyp/0.6.17/tools/gyp_addon',
  'binding.gyp',
  '-I/Users/yangzhaojie/tech/nodejs/node_modules/mysql-libmysqlclient/build/config.gypi',
  '-f',
  'make' ]
spawn make [ 'BUILDTYPE=Release', '-C', 'build' ]
  CXX(target) Release/obj.target/mysql_bindings/src/mysql_bindings.o
llvm-gcc-4.2: -E, -S, -save-temps and -M options are not allowed with multiple -arch flags
make: *** [Release/obj.target/mysql_bindings/src/mysql_bindings.o] Error 1
ERR! Error: `make` failed with exit code: 2
    at ChildProcess.onExit (/opt/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:209:23)
    at ChildProcess.emit (events.js:70:17)
    at maybeExit (child_process.js:362:16)
    at Process.onexit (child_process.js:398:5)
ERR! not ok

npm ERR! mysql-libmysqlclient[@1](/user/1).3.2 install: `node-gyp rebuild`
npm ERR! `sh "-c" "node-gyp rebuild"` failed with 1
npm ERR! 
npm ERR! Failed at the mysql-libmysqlclient[@1](/user/1).3.2 install script.
npm ERR! This is most likely a problem with the mysql-libmysqlclient 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 their info via:
npm ERR!     npm owner ls mysql-libmysqlclient
npm ERR! There is likely additional logging output above.
npm ERR! 
npm ERR! System Darwin 11.3.0
npm ERR! command "node" "/opt/local/bin/npm" "install" "mysql-libmysqlclient"
npm ERR! cwd /Users/yangzhaojie/tech/nodejs
npm ERR! node -v v0.6.17
npm ERR! npm -v 1.1.21
npm ERR! code ELIFECYCLE
npm ERR! message mysql-libmysqlclient[@1](/user/1).3.2 install: `node-gyp rebuild`
npm ERR! message `sh "-c" "node-gyp rebuild"` failed with 1
npm ERR! errno {}

npm ERR! Error: EACCES, open 'npm-debug.log'
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.
npm ERR! 
npm ERR! System Darwin 11.3.0
npm ERR! command "node" "/opt/local/bin/npm" "install" "mysql-libmysqlclient"
npm ERR! cwd /Users/yangzhaojie/tech/nodejs
npm ERR! node -v v0.6.17
npm ERR! npm -v 1.1.21
npm ERR! path npm-debug.log
npm ERR! code EACCES
npm ERR! message EACCES, open 'npm-debug.log'
npm ERR! errno {}
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /Users/yangzhaojie/tech/nodejs/npm-debug.log
npm not ok

设置CXX使用gcc和g++都是一样的,想问一下,有没有人遇到过同样的问题。高手们能知道这个错误怎么排除吗。

7 回复

下载包,手动编译

: make waf

把编译好的包,放到 node_module 下

编译完了生成了一个builde目录,看了一下这个目录下的东西,和npm安装的包目录有些差异,实在不知道是复制哪一个放到node_module下

@mackjoner 编译好后,直接把整个下载的包放到 node_modules 下, 目录名参照 package.json

@cfddream Thx,已经ok,这招很无敌了,看来要好好学习了,再次谢谢你的经验分享

centos5下 还是出现问题,make waf出现错误如下:

[root@mysql-libmysqlclient]# make waf touch waf-stamp node-waf configure build Checking for program g++ or c++ : /usr/bin/g++ Checking for program cpp : /usr/bin/cpp Checking for program ar : /usr/bin/ar Checking for program ranlib : /usr/bin/ranlib Checking for g++ : ok
Checking for node path : not found Checking for node prefix : ok /usr/local Checking for header mysql.h : yes Checking for library mysqlclient_r : not found /home/sdq/node_modules/mysql-libmysqlclient/wscript:43: error: Missing thread-safe libmysqlclient_r library from libmysqlclient-devel or mysql-devel package make: *** [waf-stamp] 错误 1

yum install mysql-devel

mark

OS X下需要将mysql的bin加入PATH环境变量,mysql的lib加入DYLD_LIBRARY_PATH环境变量。还需要执行:sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer

回到顶部