我從XAMPP使用OSX 10.6.8和MySQL。從node.js應用程序連接到mysql,錯誤:「dyld:懶惰符號綁定失敗:找不到符號:_mysql_init」
當我運行這個應用程序的Node.js(app.js):
var mysql = require('mysql-libmysqlclient');
var conn = mysql.createConnectionSync();
conn.connectSync('127.0.0.1', 'root', '', 'database_name');
我看到這樣的輸出:
Airs0urce:nodejs airs0urce$ node app.js
dyld: lazy symbol binding failed: Symbol not found: _mysql_init
Referenced from: /Applications/XAMPP/xamppfiles/htdocs/myproject/nodejs/node_modules/mysql-libmysqlclient/build/Release/mysql_bindings.node
Expected in: dynamic lookup
dyld: Symbol not found: _mysql_init
Referenced from: /Applications/XAMPP/xamppfiles/htdocs/myproject/nodejs/node_modules/mysql-libmysqlclient/build/Release/mysql_bindings.node
Expected in: dynamic lookup
Trace/BPT trap
谷歌搜索後,已經嘗試過幾個解決方案。從XAMPP目錄 增加MySQL庫,包括路徑是這樣的:
export DYLD_LIBRARY_PATH=/Applications/XAMPP/xamppfiles/lib/mysql:$DYLD_LIBRARY_PATH
嘗試使用MacPorts的安裝mysql5-devel
,但沒有運氣,建築失敗:
Airs0urce:~ airs0urce$ sudo port install mysql5-devel
---> Computing dependencies for mysql5-devel
---> Building mysql5-devel
Error: Target org.macports.build returned: shell command failed (see log for details)
Log for mysql5-devel is at: /opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_release_ports_databases_mysql5-devel/mysql5-devel/main.log
Error: Status 1 encountered during processing.
To report a bug, see <http://guide.macports.org/#project.tickets>
有日誌文件,如果你想看到:http://dl.dropbox.com/u/1875424/main.log