I was recently trying to install node-libmysqlclient on Mac OS X but was running into a build error saying “library not found for -lmysqlclient_r”.
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
I went through quite a bit to figure this out. First posted on Stack Overflow, then filed an issue with the developer who recommended some things to try.
After finding this stack overflow post, I realized that libmysqlclient_r is no longer provided, but should just be linked to the normal libmysqlclient.
Run the following symlink commands and the build should succeed:
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/libmysqlclient.la /usr/local/mysql/lib/mysql/libmyqslclient_r.la sudo ln -s /usr/local/mysql/lib/mysql/libmysqlclient.15.dylib /usr/local/mysql/lib/mysql/libmysqlclient_r.dylib
Simple, after hours of Google-ing.
Possibly related posts: