Skip to content

Library not found error on OS X #129

viveleroi opened this Issue May 17, 2012 · 12 comments

3 participants


I'm getting an error trying to install this via npm and I can't tell what the problem is. I posted to stack overflow with the details and one user confirms he sees the same issue.

$ npm install mysql-libmysqlclient
npm http GET
npm http 304

> mysql-libmysqlclient@1.3.3 install /Users/botskonet/node_modules/mysql-libmysqlclient
> node-gyp rebuild

info it worked if it ends with ok 
spawn python [ '/Users/botskonet/.node-gyp/0.6.12/tools/gyp_addon',
  'make' ]
spawn make [ 'BUILDTYPE=Release', '-C', 'build' ]
  CXX(target) Release/
  CXX(target) Release/
  CXX(target) Release/
  CXX(target) Release/
  SOLINK_MODULE(target) Release/mysql_bindings.node
ld: library not found for -lmysqlclient_r
collect2: ld returned 1 exit status
make: *** [Release/mysql_bindings.node] Error 1
ERR! Error: `make` failed with exit code: 2
    at Array.0 (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:176:25)
    at EventEmitter._tickCallback (node.js:192:40)
ERR! not ok

npm ERR! mysql-libmysqlclient@1.3.3 install: `node-gyp rebuild`
npm ERR! `sh "-c" "node-gyp rebuild"` failed with 1
npm ERR! 
npm ERR! Failed at the mysql-libmysqlclient@1.3.3 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" "/usr/local/bin/npm" "install" "mysql-libmysqlclient"
npm ERR! cwd /Users/botskonet/Sites/SportsBuddies
npm ERR! node -v v0.6.12
npm ERR! npm -v 1.1.15
npm ERR! message mysql-libmysqlclient@1.3.3 install: `node-gyp rebuild`
npm ERR! message `sh "-c" "node-gyp rebuild"` failed with 1
npm ERR! errno {}
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /Users/botskonet/Sites/SportsBuddies/npm-debug.log
npm not ok
@Sannis Sannis was assigned May 17, 2012
Sannis commented May 17, 2012

Look at the dependencies section in README and issues #107. To build mysql-libmysqlclient you should install both libmysqlclient and development headers for it, add path to your MySQL bin dir to $PATH and path to your MySQL lib dir to $DYLD_LIBRARY_PATH.


I've already done so. Mysql was install manually on my Mac just as I would our servers. It was ./configure'd, installed, and php was built against it so I know the header files are available. I've made sure that both the PATH and DYLD_LIBRARY_PATH are accurate yet the build of this still fails, same error.

Sannis commented May 17, 2012

Please show me output of mysql_config --libs_r.


-L/usr/local/mysql/lib/mysql -lmysqlclient_r -lz -lm

Sannis commented May 18, 2012

Please ensure that /usr/local/mysql/lib/mysql contains libmysqlclient_r* libs and show me your build/config.gypi and build/Makefile.

Sannis commented May 18, 2012

To do this you should git clone this repo and run npm install in it.


Output of the mysql lib directory, the requested files:


Any hope? I'm struggling to make this work because I need it to do work on an existing project.


Based on the last comment in this thread ( I tried linking the libs as the user suggested but it didn't work.

"Newer versions of the MySQL client distributions do not include the "_r" version. Some may have a symbolic link from libmyqslclient_r.a to libmyqslclient.a"

So if I don't have the _r - what should I do?


It seems that I needed all three items symlinked, so I did:

sudo ln -s /usr/local/mysql/lib/mysql/libmysqlclient.a /usr/local/mysql/lib/mysql/libmyqslclient_r.a
sudo ln -s /usr/local/mysql/lib/mysql/ /usr/local/mysql/lib/mysql/
sudo ln -s /usr/local/mysql/lib/mysql/libmysqlclient.15.dylib /usr/local/mysql/lib/mysql/libmysqlclient_r.dylib

And now it builds just fine.

@viveleroi viveleroi closed this May 21, 2012
akzhan commented May 22, 2012

Hm, I suppose that *_r "reentrant" libraries should be not used anymore due to its absence.

Sannis commented May 22, 2012

@botskonet thanks for your investigation!

I'll look into MySQL changelog and try to make binding.gyp compatible with newer versions. Nevertheless, if your mysql_config --libs_r suggests to use -lmysqlclient_r flag, it looks more as bug in MySQL Makefile that forgot ot create symlinks.

@Sannis Sannis reopened this May 22, 2012
@Sannis Sannis closed this May 22, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.