title: Connect to mysql from node.js app, error: "dyld: lazy symbol binding failed: Symbol not found: _mysql_init"
body: <p>I use OSX 10.6.8 and MySQL from XAMPP.</p>
  
  <p>When I run this node.js app (app.js):</p>
  
  <pre><code>var mysql = require('mysql-libmysqlclient');
  var conn = mysql.createConnectionSync();
  conn.connectSync('127.0.0.1', 'root', '', 'database_name');
  </code></pre>
  
  <p>I see this output:</p>
  
  <pre><code>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
  </code></pre>
  
  <p>Already tried couple solutions after googling. 
  Added mysql libs from XAMPP directory to include path this way:</p>
  
  <pre><code>export DYLD_LIBRARY_PATH=/Applications/XAMPP/xamppfiles/lib/mysql:$DYLD_LIBRARY_PATH
  </code></pre>
  
  <p>tried to install <code>mysql5-devel</code> using MacPorts, but no luck, building failed:</p>
  
  <pre><code>Airs0urce:~ airs0urce$ sudo port install mysql5-devel
  ---&gt;  Computing dependencies for mysql5-devel
  ---&gt;  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 &lt;http://guide.macports.org/#project.tickets&gt;
  </code></pre>
  
  <p>There is log file if you want to see: <a href="http://dl.dropbox.com/u/1875424/main.log" rel="nofollow">http://dl.dropbox.com/u/1875424/main.log</a></p>