nodejs / help

:sparkles: Need help with Node.js? File an Issue here. :rocket:
1.45k stars 278 forks source link

Unresolved external symbol issue #4209

Closed htjhin closed 2 months ago

htjhin commented 1 year ago

Details

This is what I have in the binding.gyp, and the library and DLL files are present in the folder as. The lib file is making reference to the DLL. However when node-gyp build it gives error:

addon_node.obj : error LNK2001: unresolved external symbol json_object_to_json_string_ext
addon_node.obj : error LNK2001: unresolved external symbol json_tokener_parse
addon_node.obj : error LNK2001: unresolved external symbol json_object_put

Please help how I should link the lib and the DLL.

"targets": [
        {
            "target_name": "XXX",
            "sources": [
                "addon.c",
                "addon_node.c"
            ],
            'conditions': [
                [
                    "OS == 'win'", 
                    {
                        "include_dirs": [
                            "<(module_root_dir)/include",
                        ],
                        "libraries": [
                            '-l"<(module_root_dir)/lib/json-c.lib"'
                        ],
                        "copies": [
                            {
                                "destination": "<(module_root_dir)/build/Release/",
                                "files": [
                                    "<(module_root_dir)/lib/json-c.dll"
                                ]
                            }
                        ]
                    }
                ]
            ]
        }

this is taken out from lib using dumpbin:

Archive member name at 5B1C: json-c.dll/     
FFFFFFFF time/date
         uid
         gid
       0 mode
      3F size
correct header end

  Version      : 0
  Machine      : 14C (x86)
  TimeDateStamp: FD56F3DB
  SizeOfData   : 0000002B
  DLL name     : json-c.dll
  Symbol name  : _json_object_to_json_string_ext
  Type         : code
  Name type    : no prefix
  Hint         : 75
  Name         : json_object_to_json_string_ext

Node.js version

16.17.1

Example code

No response

Operating system

Windows 11 Pro Version 10.0.22621 Build 22621

Scope

issue with node-gyp build

Module and version

Not applicable.

prettydiff commented 1 year ago

Please wrap your code into a markdown code block:

```javascript my code here ```

preveen-stack commented 12 months ago

cc @nodejs/node-gyp PTAL

github-actions[bot] commented 3 months ago

It seems there has been no activity on this issue for a while, and it is being closed in 30 days. If you believe this issue should remain open, please leave a comment. If you need further assistance or have questions, you can also search for similar issues on Stack Overflow. Make sure to look at the README file for the most updated links.

github-actions[bot] commented 2 months ago

It seems there has been no activity on this issue for a while, and it is being closed. If you believe this issue should remain open, please leave a comment. If you need further assistance or have questions, you can also search for similar issues on Stack Overflow. Make sure to look at the README file for the most updated links.