2011-11-16 71 views
1

我從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

回答

1

這是因爲,在Mac OS X獅子(10.7)一個配置問題:lib/libmysqlclient.18.dylib(MySQL的5.5及以上)。

第1步:

確保您設置的路徑~/.profile

export ARCHFLAGS=-arch x86_64 
export DYLD_LIBRARY_PATH=/usr/local/mysql/lib:$DYLD_LIBRARY_PATH 

第2步:

我使用RVM所以,我用下面的命令:

rvmsudo ARCHFLAGS="-arch x86_64" gem install mysql2 -- --with-mysql-config=/usr/local/mysql/bin/mysql_config --with-opt-lib=/usr/local/mysql/lib 

它已經解決了在Mac lion和mysql x86_64上的rails應用程序的問題。

0

我futzed圍繞這個進行了大量的時間,包括設置DVLD庫路徑和複製庫到/ usr/lib目錄下。

須藤CP /usr/local/mysql/lib/libmysqlclient.18.dylib/usr/lib目錄

哎呀,什麼都搞不定。最後,我嘗試清除64位和32位的默認值,它工作!

默認刪除com.apple.versioner.perl

不知道如果我的Perl是64位或32位,但我的數據庫是64位的,只是使用默認的缺省似乎更好地工作;-)

相關問題