【问题标题】:node-gyp resolving external library symbols on windows buildnode-gyp 在 Windows 构建上解析外部库符号
【发布时间】:2016-04-13 06:23:53
【问题描述】:

我正在尝试使用 MS VS 2015 在 Windows 10 上构建节点模块,但由于某种原因,它无法解析 node-gyp build 上的库符号。这是我的binding.gyp 文件:

{
    'variables' : {
        'include_path' : 'path/to/include',
        'lib_path': '/path/to/lib',
    },
    'targets': [
        {
            // name and sources here
            'include_dirs': [
                '<(include_path)',
            ],
            'libraries': [
                '<(lib_path)',
            ],
        },
    ],
}

由于某种原因,它无法解析库中的任何符号。这是输出的sn-p:

ProjectBuild.obj : error LNK2001: unresolved external symbol __imp__AiMsgSetLogFileFlags [\path\to\build\project_build.vcxproj]
ProjectBuild.obj : error LNK2001: unresolved external symbol __imp__AiRenderInterrupt [\path\to\build\project_build.vcxproj]

此外,这里是该库的目标文件转储中这些符号的反汇编:

Disassembly of section .text:

0000000000000000 <AiMsgSetLogFileFlags>:
   0:   ff 25 00 00 00 00       jmpq   *0x0(%rip)        # 6 <AiMsgSetLogFileFlags+0x6>
   6:   90                      nop
   7:   90                      nop

ai.dll:     file format pei-x86-64

Disassembly of section .text:

0000000000000000 <AiRenderInterrupt>:
   0:   ff 25 00 00 00 00       jmpq   *0x0(%rip)        # 6 <AiRenderInterrupt+0x6>
   6:   90                      nop
   7:   90                      nop

ai.dll:     file format pei-x86-64

我可以 100% 确定 node-gyp 正在查找库文件。有谁知道为什么在链接该文件中的符号时遇到问题?对于它的价值,我能够在 linux 环境中使用完全相同的 binding.gyp 文件构建该模块。

【问题讨论】:

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


    【解决方案1】:

    您需要考虑确保要导出的符号有这个。 https://msdn.microsoft.com/en-us/library/3y1sfaz2%28v=vs.140%29.aspx

    【讨论】:

    • 始终欢迎提供指向潜在解决方案的链接,但请add context around the link,以便您的其他用户知道它是什么以及为什么存在。始终引用重要链接中最相关的部分,以防目标站点无法访问或永久离线。考虑到仅仅是指向外部站点的链接Why and how are some answers deleted? 的一个可能原因。
    猜你喜欢
    • 2016-03-29
    • 1970-01-01
    • 2014-03-04
    • 2016-10-09
    • 2013-05-04
    • 1970-01-01
    • 1970-01-01
    • 2015-12-04
    • 1970-01-01
    相关资源
    最近更新 更多