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

对着背影说爱祢 提交于 2019-12-13 13:05:48

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/17145249/how-to-include-c-libraries-so-that-node-gyp-can-link

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!