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

编译 @kungfu-trader/kfx-broker-sim 时候报错了 #122

Open
lwgm opened this issue Jun 14, 2024 · 3 comments
Open

编译 @kungfu-trader/kfx-broker-sim 时候报错了 #122

lwgm opened this issue Jun 14, 2024 · 3 comments

Comments

@lwgm
Copy link

lwgm commented Jun 14, 2024

系统是 windows11
cmake version 3.29.5
node v14.21.3
yarn 1.22.22
python 3.9.10
pipenv version 2024.0.1
vs 2022
安装vs2022的时候选了windows sdk。

编译的时候报错

@kungfu-trader/kfx-broker-sim
$ kfs extension build
 | -- writing workflows ...
 | -- C:\Users\ll\Desktop\python\cpp\kungfu\.github\CODEOWNERS exists, skip copy
 | -- C:\Users\ll\Desktop\python\cpp\kungfu\.github\workflows\bump-major-version.yml exists, skip copy
 | -- C:\Users\ll\Desktop\python\cpp\kungfu\.github\workflows\bump-minor-version.yml exists, skip copy
 | -- C:\Users\ll\Desktop\python\cpp\kungfu\.github\workflows\release-new-version.yml exists, skip copy
 | -- C:\Users\ll\Desktop\python\cpp\kungfu\.github\workflows\release-verify.yml exists, skip copy
 | -- written to C:\Users\ll\Desktop\python\cpp\kungfu\.github
$ C:\Users\ll\Desktop\python\cpp\kungfu\node_modules\.bin\kfc engage pdm makeup
 | Changes are written to pyproject.toml.
$ C:\Users\ll\Desktop\python\cpp\kungfu\node_modules\.bin\kfc engage pdm install
\ Fetching hashes for resolved packages...
 | All packages are synced to date, nothing to do.
Installing the project as an editable package...
  v Update kfx-broker-sim 0.0.0 -> 0.0.0 successful
 |   - Updating kfx-broker-sim 0.0.0 -> 0.0.0...
 |   All complete!
 |   - Updating kfx-broker-sim 0.0.0 -> 0.0.0...
$ C:\Users\ll\Desktop\python\cpp\kungfu\node_modules\.bin\kfc engage nuitka --module --assume-yes-for-downloads --remove-output --no-pyi-file --include-package=sim --output-dir=dist\sim src\python\sim
 | Nuitka-Options:INFO: Used command line options: --module --assume-yes-for-downloads --remove-output --no-pyi-file --include-package=sim --output-dir=dist\sim src\python\sim
 | Nuitka:INFO: Starting Python compilation with Nuitka '1.5.8' on Python '3.9' commercial grade 'not installed'.
 | Nuitka:INFO: Completed Python level compilation and optimization.
 | Nuitka:INFO: Generating source code for C backend compiler.
 | Nuitka:INFO: Running data composer tool for optimal constant value handling.
 | Nuitka:INFO: Running C compilation via Scons.
 | Nuitka-Scons:INFO: Backend C compiler: cl (cl 14.3).
FATAL: Error, the Windows SDK must be installed in Visual Studio.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
 | Failed to execute $ yarn kfc engage nuitka --module --assume-yes-for-downloads --remove-output --no-pyi-file --include-package=sim --output-dir=dist\sim src\python\sim
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
 | `yarn build` failed with exit code 1
Stopping 10 active children

安装Visual Studio.时候,把windows的sdk都勾上,是不是还有什么其他的地方没有配置对?
image

@lwgm
Copy link
Author

lwgm commented Jun 20, 2024

参照https://docs.kungfu-trader.com/latest/10-development.html#setup
使用vs自带的 x64 Native Tools Command Prompt VS 2022 可以编译成功了。

运行的时候,运行不了....
kungfu

@GCWK
Copy link

GCWK commented Jun 24, 2024

@lwgm

[Debug]

核心是第1,2步,先定位具体crash的问题

  1. 定位到问题是electron触发了 render-process-gone 事件,导致crash了,那就进行debug,参考:Electron 中的 crash 上报和 dump 分析 ,生成 dmp 文件即可
    屏幕截图 2024-06-24 155117
  2. 直接使用 vs2022 打开 dmp 文件,进行调试,定位到问题是msvcp140.dll的版本问题(本地已经更新过,错误信息可能是“未找到metux.C”),参考。Access violation with std::mutex::lock after upgrading to VS 2022 version 17.10.0
    屏幕截图 2024-06-24 155700
  3. 所以问题就出现在编译后 ...core\dist\kfc\MSVCP140.dll 的版本跟vs 2022 17.10所需要的版本不匹配,前提是已经安装了最新的vc_redist
  4. 最终将 C:\Windows\System32下msvcp140.dll (留意是否是14.40.xxxx版本)拷贝到 ...core\dist\kfc 目录下覆盖即可

@kungfu-origin

[疑问]

因为本地 vc_redist 早已更新为最新版本,和 vs2022 是匹配的,但是为何编译的时候,会把低版本的 msvcp140.dll 打包进去,怀疑是vs2022自带的msvcp140.dll不匹配,是否能在编译流程中能避免

@lwgm
Copy link
Author

lwgm commented Jun 24, 2024

@lwgm

[Debug]

核心是第1,2步,先定位具体crash的问题

  1. 定位到问题是electron触发了 render-process-gone 事件,导致crash了,那就进行debug,参考:Electron 中的 crash 上报和 dump 分析 ,生成 dmp 文件即可
    屏幕截图 2024-06-24 155117
  2. 直接使用 vs2022 打开 dmp 文件,进行调试,定位到问题是msvcp140.dll的版本问题(本地已经更新过,错误信息可能是“未找到metux.C”),参考。Access violation with std::mutex::lock after upgrading to VS 2022 version 17.10.0
    屏幕截图 2024-06-24 155700
  3. 所以问题就出现在编译后 ...core\dist\kfc\MSVCP140.dll 的版本跟vs 2022 17.10所需要的版本不匹配,前提是已经安装了最新的vc_redist
  4. 最终将 C:\Windows\System32下msvcp140.dll (留意是否是14.40.xxxx版本)拷贝到 ...core\dist\kfc 目录下覆盖即可

@kungfu-origin

[疑问]

因为本地 vc_redist 早已更新为最新版本,和 vs2022 是匹配的,但是为何编译的时候,会把低版本的 msvcp140.dll 打包进去,怀疑是vs2022自带的msvcp140.dll不匹配,是否能在编译流程中能避免

试了下替换msvcp140.dll,可以正常运行了,感谢大神。

另外,试了下,加了捕获代码,抓到dump文件,报的是未找到 mutex.c。
image

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

2 participants