esp-idf build fails with "fatal error: esp_wifi.h: No such file or directory" - visual-studio-code

I am a student who has gotten a part time job embedded system programming. I am given a program the company uses, and asked to understand it. This is a working program. Therefore, the project can be built and flashed on ESP32 by the developers with no problem. So, the code and CMake files should have no issues. However, I cannot build the program either with VSCode extension nor with idf.py. In fact, I cannot build esp-idf examples from the official website, either.
Note: I am new to StackOverflow as well as to ESP32, so sorry if I made any mistakes here. If this post is problematic in any way, please inform me.
The error message from the terminal is shown here
I was initially using VSCode on Windows 10 (Windows is not activated). At first, ESP extension was completely failing to start the building process because it could not locate the tools. I was getting "could not be located" errors for all the tools. Below is a list of what I did in this setting:
I had v5.0.0 for esp-idf downloaded from Espressif server. I deleted it and tried v4.3.3 and then I tried to download from Github server. I downloaded the requirements for idf.py scripting environment and completed the settings for it as described by the Espressif's documentation.
I manually set the environment variables for IDF_PATH and PATH for both the user and for the system.
After 2, the initial error was gone. Unfortunately, I had a new error which indicated that ".elf" file for the project output could not be found. I do not exactly recall the error but if it is integral to the problem's solution I can try to replicate this issue.
I tried to delete and reinstall VSCode. I tried running VSCode with admin authority.
I tried changing the IDF_TOOLS_PATH in the VSCode esp-idf extension configurations from ".espressif" to "esp\esp-idf".
At this point, I moved to try to build the project on Ubuntu 22.04.1 LTS:
In Ubuntu, I got the fatal error: esp_event.h: No such file or directory error.
It does not seem to be a common issue and I could not find much about it online.
I followed the Linux setup steps in the documentation. It said that only step 1 (Downloading the prerequisites) was necessary for the VSCode extension.
I decided to try the "master branch" from esp-idf configurations as well. After I downloaded the master branch, the error changed to the current version: 'fatal error: esp_wifi.h: No such file or directory'
I also tried the idf.py in Ubuntu but I got the same error.
Both in Ubuntu and in Windows, the Doctor Command returns nothing. It does not even open the terminal or any window. I am not sure what it should return but some online discussions were asking about its return so I wanted to note it here.
Edit: When I tried the examples on Ubuntu, they actually build just fine. Doctor Command also works with examples.
However, the main code has still issues. Initially, I assumed I made some mistakes with esp-idf configurations. But, perhaps that was not the case.

I had the same problem and ended up editing my project's CMakeLists.txt. When I added "esp_wifi" to the "REQUIRES" list, it worked for me:
idf_component_register(
SRCS "main.c"
INCLUDE_DIRS res
EMBED_FILES res/settings.html
REQUIRES esp_wifi
)

Related

Installing Mac VSCode extensions now failing with error: Corrupt ZIP: end of central directory record signature not found

After upgrading work Mac to Big Sur, now unable to install any VS Code extensions, where I was able to before. The error message that I am receiving is the following:
[2021-08-18 14:04:53.663] [renderer1] [error] ["validating: Corrupt ZIP: end of central directory record signature not found"," at x.downloadInstallableExtension (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/code/electron-browser/sharedProcess/sharedProcessMain.js:54:201021)"," at async x.installGalleryExtension (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/code/electron-browser/sharedProcess/sharedProcessMain.js:54:197524)"," at async vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/code/electron-browser/sharedProcess/sharedProcessMain.js:54:194563"]
I have looked at several stack overflow threads like this one:
Error "end of central directory record signature not found" while installing ionide-fsharp in vscode
I can confirm the following:
My company runs a corporate transparent proxy, so I do not have to enter a proxy in the settings. I've confirmed that I do not have this set.
I have followed the instructions to download and install the vsix file manually
Downloading looks to be successful, the python extension is 16.5 MB
The installation portion of the downloaded file fails with the same error
Confirmed that I do not have a disk space issues as someone mentioned in the above thread
I have reinstalled VSCode per these instructions: How to completely uninstall vscode on mac
I've attempted installations of VSCode 1.59 (original version) and 1.58.2, same errors
Any suggestions on where to go from here? I'm not able to install this locally, and can't seem to figure out what may be causing the issue.
I have confirmed with other team members that they're not running into my issue, and they have successfully upgraded to Big Sur. I don't think that's the cause, but that's the only change to my workstation that I can think of.
This worked for me:
Try downloading the vsix file of the extension from its github release page (make sure the extension version is compatible with your vscode version)
Disable your internet connection and install the vsix file via vscode.

Why is VS Code throwing this error (ARDUINO)?

Okay, so I'm trying to code & upload to an Arduino with VS Code (Visual Studio Code). When I try to upload or verify my Arduino code, this error pops up:
If you cannot see that, it says:
[Starting] Verify sketch - ir_remote\ir_remote.ino [Warning] Output path is not specified. Unable to reuse previously compiled files. Verify could be slow. See README. Arduino: This application was configured to use a bundled Java Runtime Environment but the runtime is missing or corrupted. [Error] Exit with code=1
Help will be greatly appreciated. I started messing around with the Arduino a few weeks ago, and I've been using VS Code for a long time.
ALSO:
Code works completely fine on Arduino IDE, I want to be able to code and upload to an Arduino with VS Code.
I also tried posting this on the Arduino Forum, and no one replied.
I was able to solve the issue sharing here to help,
I installed Arduino from MS App Store, and i got exactly same error, i uninstalled the Arduino and downloaded installer from Arduino web site, i installed Arduino set the path by pointing to in VS Code settings > extensions > Arduino Configurations > Arduino Path, paste here path to installation folder. And it was all good.
Under project files .vscode folder be sure arduino.json has path set to
"output": "../ArduinoOutput",
Remember that you have to select Development board, Programmer and Serial Port as well in VS Code IDE.
Please View
https://maker.pro/arduino/tutorial/how-to-use-visual-studio-code-for-arduino
Abolfazl Danayi 5 months ago
Salaam
I had the same problem and after following the very nice instructions of the author and what Jack said, I found this:
Add "output": "./build" (or wherever you want) to your ".vscode/arduino.json" file, just as Jack mentioned.
Delete ".vscode/c_cpp_properties.json" file. (If you don't do this, the intellisense won't work).
Build the project again (via verification or upload buttons).
Enjoy (And hope the bests for me in the case your problem is done following this routine!)

A fatal error was encountered. The library 'hostpolicy.dll' required to execute the application was not found

I tried internet search on this issue and it is very common with many suggestions. The problem started with an update to VS2019 in which I paused because my projects in VSCode were breaking.I did a system restore and when I tried to start VSCode I got a message saying my installation was corrupt. So I reinstalled to the latest version and now get this error.
A fatal error was encountered. The library 'hostpolicy.dll' required to execute the application was not found...
I found 3 extensions that needed updating so I do so but did not fix this problem. Do not know if I need to update the .Net Core since it looks like a version mismatch. It seems these updates are wreckless since they always cause thing to go wrong.s
If you are facing this problem, it means you are using Windows.
This official microsoft live share github page explains how to fix the issue: https://github.com/MicrosoftDocs/live-share/issues/102
Especially, check out this comment: https://github.com/MicrosoftDocs/live-share/issues/102#issuecomment-366509735
make vscode is up to date
uninstall live share from vscode
close vscode completely
restart vscode as administrator
reinstall live share
I should add:
close completely vscode and restart it

What are the steps to package and release VS Code?

I am trying to figure out how to package an unchanged fork of VS Code.
My first steps were to follow the electron application distubution documentation, which has not been successful. I also found this post, where another user had the same question. However, the vscode-win32 gulp task seems to have been replaced by x64 and ia32 versions, and when I try running these tasks they generate an out-vscode folder as opposed to a full electron project.
This led me to believe that I can use this new out folder (as well as node modules, packages.json, etc.) with the electron release being used by VS Code to mimic the resources/app folder from the installed version of VS Code in Program Files, however when I try running electron.exe using this method I get:
The factory method of "vs/code/electron-main/main" has thrown an exception TypeError: Path must be a string. Received undefined
In short, I have been struggling with this for a couple of days, and I am out of ideas. If anyone has packaged the project and can offer a suggestion for how to do so, I would really appreciate it.
SOLVED
The issue seemed to be due to being branched off of master as opposed to release. I'd assume there are changes in main that aren't accounted for in the gulp task.
For anyone confused by my post, the expected behavior for a successful build is for a folder named VSCode-win32-x64 to be generated in the directory where your vscode clone is located.

Why can I not compile TypeScript anymore?

I'm doing some web development and I did a commit & sync via GitHub's Mac GUI, then I installed some Mac updates that required a restart (I don't know what the updates were). When I opened my project in PHPStorm again, I found this error when I tried compiling my TypeScript:
/usr/local/bin/tsc
env: node: No such file or directory
I know the compilation was working before. My web application had no issues. This question deals specifically with me being able to do this yesterday, with no changes to the FileWatcher configuration.
I have my TypeScript Compiler in usr/local/bin/tsc (which I have checked as a valid path to a typescript compiler alias). When I click on the alias, It opens a terminal window and runs typescript, so I know it's there. PHPStorm also complains if I try to change the file path, saying I must pick a valid executable.
I modified my Environment Variables on the advice of Dan Clark's site but that hasn't changed anything. I don't have the reputation to upload a photo of my File Watchers Dialog.
Does anyone know why I am getting this error, and how it can be fixed? I mention GitHub because that's the last thing I did before things stopped working: a commit & sync, then a restart to install some Mac updates.
Both which node and which tsc point in the right direction. Just tsc also works.
My solution was to use the directory of the actual TypeScript compiler at /usr/local/lib/node_modules/typescript/bin/tsc
instead of
/usr/local/bin/tsc, which is the alias.
That lets me compile using the FileWatcher.
As for why this happened, it's still a mystery to me.