vscode esp-idf cannot open source file

zazas321
Posts: 231
Joined: Mon Feb 01, 2021 9:41 am

vscode esp-idf cannot open source file

Postby zazas321 » Wed Aug 11, 2021 7:36 am

Hello. I have problems with opening esp-idf component files. Sometimes I want to have a look at the header files of the component and see whats going on, I have followed this guide:
https://www.youtube.com/watch?v=aQi8qiW ... lijaBobija

After this guide, the "stdio.h" library became fixed, but other esp-idf components are still broken.

I have created a simple hello world example and pasted the c_cpp_properties.json file in .vscode folder.
See the image below:
https://ibb.co/yfmGr2W

for exaple I want to open freertos/task.h and see whats going on there, but it wont let me.

The code compiles and runs fine, is just that I cannot open these files from the vscode. Usually I right click on the include and I can choose "go to declaration" or "go to definition"

ns1668
Posts: 50
Joined: Tue Mar 16, 2021 2:00 pm

Re: vscode esp-idf cannot open source file

Postby ns1668 » Wed Aug 11, 2021 8:46 am

This is probably because VSCode does not know where to find the header files for the esp-idf components.

You can fix this by editing your IntelliSense Configuration.

There is a section in the settings called "Include Path"
You should add the esp-idf components folder to it:

${workspaceFolder}/**
C:\Code\esp-idf\components\**

zazas321
Posts: 231
Joined: Mon Feb 01, 2021 9:41 am

Re: vscode esp-idf cannot open source file

Postby zazas321 » Wed Aug 11, 2021 9:31 am

Thanks for the response. I have created a brand new project just so everything is clear and simple. I have picked up wifi station example from esp-idf.


All I have done is created .vscode folder and inside this .vscode folder created c_cpp_properties.json with the following config:

Code: Select all

{
    "configurations": [
        {
            "name": "Linux",
            "cStandard": "c11",
            "cppStandard": "c++17",
            "includePath": [
                "${config:idf.espIdfPath}/components/**",
                "${workspaceFolder}/**"
            ],
            "browse": {
                "path": [
                    "${config:idf.espIdfPath}/components"
                ],
                "limitSymbolsToIncludedHeaders": false
            },
            "compileCommands": "${workspaceFolder}/build/compile_commands.json"
        }
    ],
    "version": 4
}
I believe this is the intellisense configuration as you have mentioned.


The results are very strange , check the image:
https://ibb.co/3dgg693


Some components such as freertos/task.h and freertos/event_groups.h and eso_event.h are found and linked properly. The others have problems.

For example when I hover over #include "esp_wifi.h" it says "cannot open source file "stdint.h (dependancy of "esp_wifi.h")

zazas321
Posts: 231
Joined: Mon Feb 01, 2021 9:41 am

Re: vscode esp-idf cannot open source file

Postby zazas321 » Wed Aug 11, 2021 10:14 am

I may have found what was causing me temporary issues. Under my main/CMakeLists.txt I had a REQUIRES option to include my custom library. When I delete this, all components are linked and found properly.

Now there is another issue, how do I add my custom library? I have created component but it does not work

Who is online

Users browsing this forum: No registered users and 231 guests