node-gyp: "..\src\binding.cc: no such file or directory"

huangapple go评论77阅读模式
英文:

node-gyp: "..\src\binding.cc: no such file or directory"

问题

我在使用electron-builder构建Electron应用程序时遇到了“..\src\binding.cc: 文件或目录不存在”的问题。日志如下:

⨯ node-gyp.cmd 退出并显示 ERR_ELECTRON_BUILDER_CANNOT_EXECUTE 错误代码
输出:
警告:缺少输入文件:
C:\Users\%user%\source\repos\electronvueapp\build\..\src\binding.cc
�믮������ ��᫥����⥫쭠� ᡮઠ �஥�⮢ � �⮬ �襭��。�⮡� ������� ��ࠫ������ ᡮ��,������� ��ࠬ��� "-m"。
  binding.cc
c1xx:致命错误 C1083:�� 㤠���� ������ 䠩� ���筨�:..\src\binding.cc:找不到文件或目录,[C:\Users\%user%\source\repos\electronvueapp\build\binding.vcxproj]

通过Google搜索,我主要得到了类似于以下链接引用的结果:https://stackoverflow.com/questions/44357010/node-gyp-build-fatal-error-c1083

常见的解决方案是在该路径下创建一个空的“binding.cc”文件,但我的问题是,每次我尝试构建应用程序时,它都会删除“build”文件夹并创建一个新的文件夹,但其中没有“binding.cc”文件。

英文:

I have stumbled upon "..\src\binding.cc: no such file or directory" when building an Electron app with electron-builder. Log:

⨯ node-gyp.cmd exited with code ERR_ELECTRON_BUILDER_CANNOT_EXECUTE
Output:
Warning: Missing input files:
C:\Users\%user%\source\repos\electronvueapp\build\..\src\binding.cc
�믮������ ��᫥����⥫쭠� ᡮઠ �஥�⮢ � �⮬ �襭��. �⮡� ������� ��ࠫ������ ᡮ��, ������� ��ࠬ��� "-m".
  binding.cc
c1xx : fatal error C1083: �� 㤠���� ������ 䠩� ���筨�: ..\src\binding.cc: No such file or directory, [C:\Users\%user%\source\repos\electronvueapp\build\binding.vcxproj]

Googling mostly gave me results alike referenced here: https://stackoverflow.com/questions/44357010/node-gyp-build-fatal-error-c1083

The common solution is to just create an empty "binding.cc" at the path, but my problem is that every time I try to build the app it just removes the "build" folder and makes a new one, but without the "binding.cc" in it

答案1

得分: 1

构建和 bin 文件夹将在每次安装时删除。您可以更改构建文件夹的名称为其他任何名称。
示例目录:

-dir_of_cc
    -binding.cc
-binding.gyp

binding.gyp 文件中的 Binding 属性对象:

{
    "target_name": "binding-name",
    "cflags!": [ "-fno-exceptions" ],
    "cflags_cc!": [ "-fno-exceptions" ],
    "sources": ["dir_of_cc/binding.cc"],
    'include_dirs': [
        "<!@(node -p \"require('node-addon-api').include\")"
    ],
    'libraries': [],
    'dependencies': [
        "<!@(node -p \"require('node-addon-api').gyp\")"
    ],
    'defines': [ 'NAPI_DISABLE_CPP_EXCEPTIONS' ]
}
英文:

Build and bin folders will be delete every install. You can change the build folder name anything else.
Sample directory:

-dir_of_cc
    -binding.cc
-binding.gyp

Binding attribute object in binding.gyp file:

{
    &quot;target_name&quot;: &quot;binding-name&quot;,
    &quot;cflags!&quot;: [ &quot;-fno-exceptions&quot; ],
    &quot;cflags_cc!&quot;: [ &quot;-fno-exceptions&quot; ],
    &quot;sources&quot;: [&quot;dir_of_cc\binding.cc&quot;],
    &#39;include_dirs&#39;: [
        &quot;&lt;!@(node -p \&quot;require(&#39;node-addon-api&#39;).include\&quot;)&quot;
    ],
    &#39;libraries&#39;: [],
    &#39;dependencies&#39;: [
        &quot;&lt;!(node -p \&quot;require(&#39;node-addon-api&#39;).gyp\&quot;)&quot;
    ],
    &#39;defines&#39;: [ &#39;NAPI_DISABLE_CPP_EXCEPTIONS&#39; ]
}

huangapple
  • 本文由 发表于 2023年1月10日 18:18:39
  • 转载请务必保留本文链接:https://go.coder-hub.com/75068510.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定