Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to include c++ libraries so that node-gyp can link?

I am writing nodejs code and want to use C++ code (backend.cpp which includes 'mysql/mysql.h') using node-gyp to compile. I am getting this error while building:

module.js:356 Module.extensions[extension](this, filename); ^ Error: ____/build/Release/backend.node: undefined symbol: mysql_init

Can anyone help? How can I instruct node-gyp to link mysql.h to the target backend.node?

like image 405
user2492926 Avatar asked Nov 03 '22 20:11

user2492926


1 Answers

Have you added it in the libraries list in your binding.gyp file?

Here's a short example:

{
  "targets": [
    {
      "target_name": "backend",
      "sources": [<comma separated source names>],
      "include_dirs":[<comma separated include dirs>],
      "libraries": [<comma separated library paths>]
    }
  ]
}

You should also take a look at the complete Gyp Language Specification

like image 85
herbstnebel_ Avatar answered Nov 11 '22 03:11

herbstnebel_