ninja:错误:加载'build.ninja':系统找不到指定的文件。当在 Visual Studio 中构建 hello world 时

问题描述 投票:0回答:5

我按照 esp-idf 指南安装并测试构建 hello world 和眨眼示例代码,但这两个代码都遇到了这个问题。

Visual studio try to build hello world

> Executing task: ninja  <

ninja: error: loading 'build.ninja': The system cannot find the file specified.

The terminal process "C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe -Command ninja " terminated with exit code: 1.

我已经测试了所有可以找到的修复方法,但我不确定我是否错过了什么。

这是我测试的方法之一,但也遇到了一些问题。 cmd try to run the command below

C:\Espressif\frameworks\esp-idf-v4.4>python -m pip install --user -r %IDF_PATH%/requirements.txt
    ERROR: Can not perform a '--user' install. User site-packages are not visible in this virtualenv.

这个可能的问题是Python环境存在,所以我无法执行此命令,但我尝试了很多方法来禁用或停用它仍然不能。

python path

system environment

visual-studio esp32
5个回答
1
投票

在尝试调试很长时间后,我制作了整个项目文件夹的备份副本,然后疯狂删除文件。我删除了几乎所有不是我创作的文件。只剩下

main/CMakeLists.txt
main/component.mk
main/main.c
main/main.h
.gitignore
CMakeLists.txt
Makefile
。然后我运行了
idf.py set-target esp32
idf.py -p /dev/ttyACM0 flash monitor
,它再次正常工作。

Ubuntu 20.04.05 LTS 上的 VS Code 和 ESP-IDF


1
投票

检查编译器是否选择正确。如果您没有选择正确的 c/c++ 编译器,那么您可能会收到此错误。我的系统中有 mingw,但 VS Code 没有自动检测编译器。然后我手动添加了mingw并选择它进行编译,之后这个问题就解决了。


0
投票

更新到新的稳定版本(v5.0)后对我有用的是

  1. 转到文件夹S:sp sp-idf sp-idf-v5.0
  2. 在此目录下运行命令提示符并执行
    install.bat
    及稍后的
    export.bat
  3. 尝试在 VSCode 中构建程序后,出现错误“ninja:错误:加载'build.ninja'”。
  4. 使用
    ESP-IDF:Configure Paths
  5. 更新 VSCode 中 ESP-IDF 扩展中的路径
  6. 找到您的项目文件夹,例如“V:\simpleTest_using_EspIDF_v5_0”
  7. 打开命令提示符并执行:
    idf.py build
  8. 现在它也可以使用 Espressif IDF 扩展在 VSCode 中构建。

0
投票

没有

ninja.build
存在是忍者未构建的症状,这可能是由多种原因引起的。对我来说,这发生在我运行命令之后:

git clone https://github.com/microsoft/vcpkg
cd vcpkg
.\bootstrap-vcpkg.bat
.\vcpkg install openblas:x64-windows
Computing installation plan...
A suitable version of cmake was not found (required v3.29.0) Downloading portable cmake 3.29.0...
Downloading cmake...
https://github.com/Kitware/CMake/releases/download/v3.29.0/cmake-3.29.0-windows-i386.zip->C:\Users\Michael Currie\Desktop\GitHub\vcpkg\downloads\cmake-3.29.0-windows-i386.zip
Downloading https://github.com/Kitware/CMake/releases/download/v3.29.0/cmake-3.29.0-windows-i386.zip
Extracting cmake..

问题1:正在下载i386版本的cmake!但我的电脑是64位的!

PS C:\Users\Michael Currie> wmic os get osarchitecture
OSArchitecture
64-bit

哦,

vcpkg
,你这个可爱的夏天孩子,下载前请检查计算机的架构
cmake
- 你抓错版本了!!

问题2:我路径中的cmake版本是3.26,即使在上述尝试安装3.29之后仍然在使用。因此要解决这两个问题:

问题3:我需要在PowerShell 7.0或更高版本中运行上述命令。所以我需要:

问题4问题仍然存在,但根据https://github.com/microsoft/vcpkg/issues/29702我需要安装带有C++的Visual Studio桌面开发以及Windows 10 SDK。所以我就这么做了。

解决上述 4 个问题后,我从计算机中完全删除了 vcpkg 文件夹,然后运行上面列出的第一条命令,构建 openblas 成功了!耶。


-3
投票

您没有

build.ninja
文件。在项目上找到这个文件

© www.soinside.com 2019 - 2024. All rights reserved.