title: Connecting to DB2 from Node.js on Linux-platform
body: <p>I am trying to connect to DB2 from a node.js application.  I have decided to use the <a href="https://npmjs.org/package/db2" rel="nofollow noreferrer">db2 node module</a>.  The instructions for installing <code>db2.js</code> first tell you to install <code>node-gyp</code> like this:</p>
  <p><code>sudo npm install -g node-gyp</code></p>
  <p>That seems to have worked for me.<br />
  Then I try to install db2.js with this command:</p>
  <p><code>sudo npm install -g db2</code></p>
  <p>Then I get this error:</p>
  <pre><code>...
  cc1plus: error: unrecognized command line option &quot;-std=c++0x&quot;
  ...
  gyp ERR! node -v v0.10.9
  gyp ERR! node-gyp -v v0.9.6
  </code></pre>
  <p>Looking at the <a href="https://github.com/TooTallNate/node-gyp" rel="nofollow noreferrer">prereqs for node-gyp</a>, it says I need gcc.  Doing a man on gcc on my system shows that the <code>-std</code> option is only supporting some really old compilers like <code>c++98</code>, <code>gnu99</code>, etc.  I have gcc version <code>4.1.2 20080704 (Red Hat 4.1.2-50)</code>.</p>
  <p>So I have a few questions.  Is there another way to connect to db2 from node?  If I continue with db2.js, then what do I need to do now, upgrade my gcc or install a <code>c++0x</code> compiler?  (I think that's C++ version 11).</p>
  <p>Wish me luck.</p>
  <h3>EDIT:</h3>
  <p>I am having trouble upgrading gcc on my linux server, so I tried installing on my raspberry pi as a test:</p>
  <pre><code>sudo npm install -g node-gyp
  cd /usr/lib/node_modules
  sudo git clone https://github.com/herzi/db2.js.git
  sudo node-gyp configure
  sudo node-gyp build
  </code></pre>
  <p>On the last command I get this error:</p>
  <pre><code>In file included from ../src/binding.cc:3:0:
  ../src/connection.hh:6:20: fatal error: sqlcli.h: No such file or directory
  compilation terminated.
  </code></pre>
  <p>I am guessing that's the DB2 Client header file, so I probably need to install that also.</p>
  <h3>EDIT 2</h3>
  <p>I installed <code>gcc</code> on my system in a different directory.  Then I changed the symlinks in <code>/usr/bin</code> for <code>gcc</code> and <code>g++</code> to point at my new gcc and g++ (inside gcc).  Now I get the same <code>sqlcli.h</code> error that I get on my pi.  Time to get the DB2 Client.</p>
  <p>Meh.  I have db2 client 9.1.2.  I need 9.7 according to some searching in the db2 <code>binding.gyp</code> file.</p>
  <h3>EDIT 3</h3>
  <p>I installed &quot;IBM Data Server Runtime Client V9.7&quot;, but it does not have <code>sqlcli.h</code> in the <code>/opt/IBM/db2/V9.7/include</code> folder!  I have a V9.1.3 on a different machine which does have a include folder.  So I installed <a href="http://jessemon.blogspot.com/2012/02/perl-dbddb2-dbi-so-not-fun.html" rel="nofollow noreferrer">&quot;IBM Data Server Client 9.7&quot; using an old blog post</a> of mine to help me.  Now I am getting an error from the node-gyp build that <code>strcmp</code> was not declared.  I bet I need to set a lib include or node environment var.</p>