Node GYP Static Library on Windows

2019-04-15 17:23发布

问题:

I'm trying to link a Static Library to a node.js addon in windows.

I used Visual Studio 2013 Express to create a .lib library and I link it in the binding.gyp file as follows:

{
  "targets": [
    {
      "target_name": "modbus",
      "sources": [
        "modbus.cc"
      ],
      "include_dirs": [
        "<!(node -e \"require('nan')\")",
        "lib/libmodbus/src"
      ],
      "libraries": [
        "-l<(module_root_dir)/lib/libmodbus/src/win32/modbus.lib"
      ]
    }
  ]
}

When I run node-gyp rebuild I recieve errors like:

modbus.obj : error LNK2001: external symbol __imp_modbus_connect not resolved

It's clear that it doesn't find the library methods. What do I do wrong?