【问题标题】:How to include c++ libraries so that node-gyp can link?如何包含 c++ 库以便 node-gyp 可以链接?
【发布时间】:2013-06-17 10:22:48
【问题描述】:

我正在编写 nodejs 代码,并希望使用 node-gyp 使用 C++ 代码(包括 'mysql/mysql.h' 的 backend.cpp)进行编译。我在构建时遇到此错误:

module.js:356 Module.extensions[extension](this, filename); ^ 错误:____/build/Release/backend.node:未定义符号:mysql_init

有人可以帮忙吗?如何指示 node-gyp 将 mysql.h 链接到目标 backend.node?​​p>

【问题讨论】:

    标签: c++ node.js node-gyp


    【解决方案1】:

    您是否已将其添加到您的 binding.gyp 文件的 libraries 列表中?

    这是一个简短的例子:

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

    你还应该看看完整的Gyp Language Specification

    【讨论】:

      猜你喜欢
      • 2018-05-22
      • 2013-04-19
      • 2015-11-20
      • 1970-01-01
      • 1970-01-01
      • 2015-06-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多