changing from Linux to Windows

User avatar
mzimmers
Posts: 643
Joined: Wed Mar 07, 2018 11:54 pm
Location: USA

changing from Linux to Windows

Postby mzimmers » Sat Nov 06, 2021 10:40 pm

Hi all -

I've been running VS Code with the ESP-IDF extension on a VirtualBox client for a couple months now. For whatever reason, I've found it very hard to flash a device through VB, so I want to try using VS Code in Windows.

I did a fresh install of the IDF (and tools, etc), and cloned my project from bitbucket. When I try to build, though, I get some errors:
vscode.PNG
vscode.PNG (109.26 KiB) Viewed 10364 times
Can someone tell me what I'm doing wrong? Was it a mistake to try to reuse my Linux .vscode files?

Thanks...

ESP_bignacio
Posts: 227
Joined: Wed May 02, 2018 12:12 pm

Re: changing from Linux to Windows

Postby ESP_bignacio » Mon Nov 08, 2021 1:13 pm

Well there are several things here as mentioned in the Problems tab:

Environment variables are referenced different in Windows than Linux. For a cross platform approach, try to use

Code: Select all

${env:<var>}
for example

Code: Select all

${env:IDF_PATH}
.

The compiler path is different in Windows. Check your ESP-IDF setup location for xtensa-esp32-elf-gcc. Something like

Code: Select all

C:\\.espressif\\tools\xtensa-esp32-elf\\{version}\\xtensa-esp32-elf\\bin\\xtensa-esp32-elf-gcc
compile_commands.json probably doesn't exist if you haven't built your project yet.

User avatar
mzimmers
Posts: 643
Joined: Wed Mar 07, 2018 11:54 pm
Location: USA

Re: changing from Linux to Windows

Postby mzimmers » Mon Nov 08, 2021 3:09 pm

Hi bignacio -

Thanks for the information; I did find the template in the docs for the file, and it now looks like this:

Code: Select all

{
    "configurations": [
      {
        "name": "ESP-IDF",
        "cStandard": "c11",
        "cppStandard": "c++17",
        "includePath": [
          "${config:idf.espIdfPath}/components/**",
          "${config:idf.espIdfPathWin}/components/**",
          "${workspaceFolder}/**"
        ],
        "browse": {
          "path": [
            "${config:idf.espIdfPath}/components",
            "${config:idf.espIdfPathWin}/components",
            "${workspaceFolder}"
          ],
          "limitSymbolsToIncludedHeaders": false
        }
      }
    ],
    "version": 4
  }
It now behaves much better, but I think I need to add the path to the system includes (found in my .espressif/tools folder), because the IDE is telling me it can't find files like stdlib.h, stddef.h, etc.

Do I need to hard-code those paths in this file, or is there a notation analogous to the ${env:IDF_PATH} you mentioned below?

Thanks...

ESP_bignacio
Posts: 227
Joined: Wed May 02, 2018 12:12 pm

Re: changing from Linux to Windows

Postby ESP_bignacio » Tue Nov 09, 2021 6:42 am

I would recommend to add compilerPath to xtensa's gcc for the C/C++ extension to pick up basic c libraries and use the compile_commands.json if you are able to build successfully for more accuracy.

User avatar
mzimmers
Posts: 643
Joined: Wed Mar 07, 2018 11:54 pm
Location: USA

Re: changing from Linux to Windows

Postby mzimmers » Tue Nov 09, 2021 2:57 pm

Hi bignacio -

I did this:

Code: Select all

{
    "configurations": [
        {
            "name": "ESP-IDF",
            "cStandard": "c11",
            "cppStandard": "c++17",
            "includePath": [
                "${config:idf.espIdfPath}/components/**",
                "${config:idf.espIdfPathWin}/components/**",
                "C:/Users/mzimmers/.espressif/tools/xtensa-esp32-elf/esp-2021r1-8.4.0/xtensa-esp32-elf/xtensa-esp32-elf/**",
                "C:/Users/mzimmers/.espressif/tools/xtensa-esp32-elf/esp-2021r1-8.4.0/xtensa-esp32-elf/lib/gcc/xtensa-esp32-elf/8.4.0/include/**",
                "${workspaceFolder}/**"
            ],
            "browse": {
                "path": [
                    "${config:idf.espIdfPath}/components",
                    "${config:idf.espIdfPathWin}/components",
                    "${workspaceFolder}/**"
                ],
                "limitSymbolsToIncludedHeaders": false
            }
        }
    ],
    "version": 4
}
Still get errors.

What exactly would I do with compile_commands.json?

Thanks!

Who is online

Users browsing this forum: No registered users and 12 guests