title: How to use c/c++ library with Javascript?
body: <p>I have a SDK from a third party. I don't have the source code, just the headers, dll and lib files. This SDK provides C APIs to communicate with a device through USB. I'd like to use this SDK in Javascript. </p>
  
  <p>I've search on this topic and there are a few approaches.  However, based on my understanding, each of them has some difficulties to be readily applied to my situation:</p>
  
  <ol>
  <li>emscripten - require all source code to be compiled into bitcode,
  which I don't have. And it also has limitations on what c++ code can be successfully parsed.</li>
  <li>SWIG - has some known issues that are non-trival.
  E.g., long long is not supported, Javascript callbacks are not
  supported (I don't understand about this one, does this mean the js
  code that calls the c/c++ lib cannot use callback function?) </li>
  <li>Node gyp - seems you have to be familiar with the V8 source and
  several other libs before you can get it done.</li>
  <li>WebIDL - not quite sure about what its about, how much effort it
  requires to get it work, if it's possible at all.</li>
  </ol>
  
  <p>Any thoughts/suggestions are welcome!</p>
  
  <p>Edit 1:  the context is that I'd like to get that data from the device into a browser, or a stand-alone node-webkit app. Similar to the use case that to get geolocation info in a browser.
  In general, I don't think my question (use C++ component with JS) is a bizaare idea. For example, Mozilla developed lots of XPCOM components in C++, then wrapped with XPConnect so that those components can be used by Javascript in Firefox, or an XUL project. But this approach is very labor intensive and put too much dependencies on Mozilla's toolchain.  Node js looks like a promising alternative.  Node-webkit is essentially doing the same thing as XUL: help building/running a cross-platform GUI app based on browser.</p>