Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

编译运行受阻 #13

Open
wildfire810 opened this issue Oct 27, 2024 · 0 comments
Open

编译运行受阻 #13

wildfire810 opened this issue Oct 27, 2024 · 0 comments

Comments

@wildfire810
Copy link

作者你好。我遇到一个状况。
windows11环境,awtk源代码在mingw64用scons编译正常,同样作为基础,在mingw64中用scons编译quickjs的绑定也正常,都能正确运行。使用mingw64的gcc编译器。
然后我想要编译awtk-nodejs,仍然用mingw64环境,nodejs和python等,都是用mingw64的pacman安装。运行node-gyp configure时,自动检测到了系统上安装的msvs(vc)编译器,而不是mingw64环境的gcc。提示信息如下

$ node-gyp configure
gyp info it worked if it ends with ok
gyp info using node-gyp@10.2.0
gyp info using node@22.5.0 | win32 | x64
gyp info find Python using Python version 3.11.9 found at "C:/msys64/mingw64/bin/python3.exe"

gyp info find VS using VS2022 (17.11.35327.3) found at:
gyp info find VS "C:\Program Files\Microsoft Visual Studio\2022\Enterprise"
gyp info find VS run with --verbose for detailed information
gyp info spawn C:/msys64/mingw64/bin/python3.exe
gyp info spawn args [
gyp info spawn args 'C:\\msys64\\mingw64\\lib\\node_modules\\node-gyp\\gyp\\gyp_main.py',
gyp info spawn args 'binding.gyp',
gyp info spawn args '-f',
gyp info spawn args 'msvs',
gyp info spawn args '-I',
gyp info spawn args 'D:\\Project\\TuoSheng\\awtk-nodejs\\build\\config.gypi',
gyp info spawn args '-I',
gyp info spawn args 'C:\\msys64\\mingw64\\lib\\node_modules\\node-gyp\\addon.gypi',
gyp info spawn args '-I',
gyp info spawn args 'C:\\Users\\wildf\\AppData\\Local\\node-gyp\\Cache\\22.5.0\\include\\node\\commo
n.gypi',
gyp info spawn args '-Dlibrary=shared_library',
gyp info spawn args '-Dvisibility=default',
gyp info spawn args '-Dnode_root_dir=C:\\Users\\wildf\\AppData\\Local\\node-gyp\\Cache\\22.5.0',
gyp info spawn args '-Dnode_gyp_dir=C:\\msys64\\mingw64\\lib\\node_modules\\node-gyp',
gyp info spawn args '-Dnode_lib_file=C:\\\\Users\\\\wildf\\\\AppData\\\\Local\\\\node-gyp\\\\Cache\\
\\22.5.0\\\\<(target_arch)\\\\node.lib',
gyp info spawn args '-Dmodule_root_dir=D:\\Project\\TuoSheng\\awtk-nodejs',
gyp info spawn args '-Dnode_engine=v8',
gyp info spawn args '--depth=.',
gyp info spawn args '--no-parallel',
gyp info spawn args '--generator-output',
gyp info spawn args 'D:\\Project\\TuoSheng\\awtk-nodejs\\build',
gyp info spawn args '-Goutput_dir=.'
gyp info spawn args ]
gyp info ok

然后执行
npm install

LINK : fatal error LNK1104: 无法打开文件“awtk.lib” [D:\Project\TuoSheng\awtk-nodejs\build\awtk.vcxproj]

问题是awtk是mingw64编译的,没有.lib文件输出。我这里讨巧用libawtk.a修改名字为awtk.lib,然后拷贝到和awtk.dll同一目录。这一步可能有问题,但我不知道正确解决方案是什么。
之后npm install编译通过

  win_delay_load_hook.cc
  awtk.vcxproj -> D:\Project\TuoSheng\awtk-nodejs\build\Release\/awtk.node
gyp info ok

up to date in 5s

14 packages are looking for funding
  run `npm fund` for details

npm run build;

$ npm run build;

> awtk-js@1.0.0 build
> node-gyp configure;node-gyp --verbose build

gyp info it worked if it ends with ok
gyp verb cli [
gyp verb cli 'C:\\msys64\\mingw64\\bin\\node.exe',
gyp verb cli 'D:\\Project\\TuoSheng\\awtk-nodejs\\node_modules\\node-gyp\\bin\\node-gyp.js',
gyp verb cli 'configure;node-gyp',
gyp verb cli '--verbose',
gyp verb cli 'build'
gyp verb cli ]
gyp info using node-gyp@10.2.0
gyp info using node@22.5.0 | win32 | x64
gyp verb build type Release
gyp verb architecture x64
gyp verb node dev dir C:\Users\wildf\AppData\Local\node-gyp\Cache\22.5.0
gyp verb python C:/msys64/mingw64/bin/python3.exe
gyp verb found first Solution file build\binding.sln
gyp verb using MSBuild: C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\MSBuild.exe
gyp info spawn C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\MSBuild.exe
gyp info spawn args [
gyp info spawn args 'build\\binding.sln',
gyp info spawn args '/nologo',
gyp info spawn args '/p:Configuration=Release;Platform=x64'
gyp info spawn args ]
生成启动时间为 2024/10/27 12:53:09。

节点 1 上的项目“D:\Project\TuoSheng\awtk-nodejs\build\binding.sln”(默认目标)。
ValidateSolutionConfiguration:
  正在生成解决方案配置“Release|x64”。
项目“D:\Project\TuoSheng\awtk-nodejs\build\binding.sln”(1)正在节点 1 上生成“D:\Project\TuoSheng\awtk-nodejs\
build\awtk.vcxproj”(2) (默认目标)。
PrepareForBuild:
  已启用结构化输出。编译器诊断的格式设置将反映错误层次结构。有关详细信息,请参阅 https://aka.ms/cpp/structured-output。
InitializeBuildStatus:
  正在创建“Release/obj/awtk\awtk.tlog\unsuccessfulbuild”,因为已指定“AlwaysCreate”。
  正在对“Release/obj/awtk\awtk.tlog\unsuccessfulbuild”执行 Touch 任务。
CustomBuild:
  Copying ../awtk/bin/awtk.dll to ../build/Release
  系统找不到指定的文件。
  已复制         0 个文件。
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\VC\v170\Microsoft.CppCom
mon.targets(254,5): warning MSB8065: 项“../../awtk/bin/awtk.dll”的自定义生成成功,但尚未创建指定的输出“d:\project\tuosh
eng\awtk-nodejs\build\release\awtk.dll”。这可能会导致增量生成无法正常工作。 [D:\Project\TuoSheng\awtk-nodejs\build\aw
tk.vcxproj]
ClCompile:
  所有输出均为最新。
  所有输出均为最新。
  所有输出均为最新。
Link:
  所有输出均为最新。
  awtk.vcxproj -> D:\Project\TuoSheng\awtk-nodejs\build\Release\/awtk.node
FinalizeBuildStatus:
  正在删除文件“Release/obj/awtk\awtk.tlog\unsuccessfulbuild”。
  正在对“Release/obj/awtk\awtk.tlog\awtk.lastbuildstate”执行 Touch 任务。
已完成生成项目“D:\Project\TuoSheng\awtk-nodejs\build\awtk.vcxproj”(默认目标)的操作。

已完成生成项目“D:\Project\TuoSheng\awtk-nodejs\build\binding.sln”(默认目标)的操作。


已成功生成。

“D:\Project\TuoSheng\awtk-nodejs\build\binding.sln”(默认目标) (1) ->
“D:\Project\TuoSheng\awtk-nodejs\build\awtk.vcxproj”(默认目标) (2) ->
(CustomBuild 目标) ->
  C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\VC\v170\Microsoft.CppC
ommon.targets(254,5): warning MSB8065: 项“../../awtk/bin/awtk.dll”的自定义生成成功,但尚未创建指定的输出“d:\project\tuo
sheng\awtk-nodejs\build\release\awtk.dll”。这可能会导致增量生成无法正常工作。 [D:\Project\TuoSheng\awtk-nodejs\build\
awtk.vcxproj]

    1 个警告
    0 个错误

已用时间 00:00:00.20
gyp info ok

问题来了:node demos/demoui.js

$ node demos/demoui.js
D:\Project\TuoSheng\awtk-nodejs\node_modules\bindings\bindings.js:121
        throw e;
        ^

Error: The specified module could not be found.
\\?\D:\Project\TuoSheng\awtk-nodejs\build\Release\awtk.node
    at Module._extensions..node (node:internal/modules/cjs/loader:1614:18)
    at Module.load (node:internal/modules/cjs/loader:1282:32)
    at Module._load (node:internal/modules/cjs/loader:1098:12)
    at TracingChannel.traceSync (node:diagnostics_channel:315:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:215:24)
    at Module.require (node:internal/modules/cjs/loader:1304:12)
    at require (node:internal/modules/helpers:123:16)
    at bindings (D:\Project\TuoSheng\awtk-nodejs\node_modules\bindings\bindings.js:112:48)
    at Object.<anonymous> (D:\Project\TuoSheng\awtk-nodejs\awtk.js:1:31)
    at Module._compile (node:internal/modules/cjs/loader:1504:14) {
  code: 'ERR_DLOPEN_FAILED'
}

Node.js v22.5.0

希望可以提示解决方案。谢谢。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant