PlatformIO Community

Strange Path, Cannot open source file

I’m running Win10, VSCode, and trying to compile a test program for an Arduino Framework and ststm32 platform.

In main.cpp the first line is #include <Arduino.h> but I get the squiggly line under it and it says to update my include path and cannot open source file "variant.h" (dependency of "Arduino.h")

If I go ahead and compile I notice an odd path created:

C:\Users\georg\.platformio\packages\framework-arduinoststm32\system\STM32F4xx/stm32f4xx_hal_conf.h:4:10: fatal error: variant.h: No such file or directory

If I go to that directory files are there so it seems that the problem is that there is a forward slash before the file name instead of a back slash.

If I look at the beginning of the compile I see this:

 Executing task: C:\Users\georg\.platformio\penv\Scripts\platformio.exe run <

Processing stm32test (platform: ststm32; board: IOTech_STM32F405; framework: arduino)
-----------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/ststm32/IOTech_STM32F405.html
PLATFORM: ST STM32 5.7.0 > IOTech Villara Tester
HARDWARE: STM32F405RGT6 168MHz, 192KB RAM, 1MB Flash
DEBUG: Current (stlink) External (stlink)
PACKAGES: framework-arduinoststm32 3.10700.191028 (1.7.0), toolchain-gccarmnoneeabi 1.70201.0 (7.2.1)
Warning! Cannot find linker script for the current target!

LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 10 compatible libraries
Scanning dependencies...     
No dependencies
Building in release mode
Compiling .pio\build\stm32test\FrameworkArduino\HardwareSerial.cpp.o
Compiling .pio\build\stm32test\FrameworkArduino\HardwareTimer.cpp.o
Compiling .pio\build\stm32test\FrameworkArduino\IPAddress.cpp.o
Compiling .pio\build\stm32test\FrameworkArduino\Print.cpp.o
Compiling .pio\build\stm32test\FrameworkArduino\RingBuffer.cpp.o
Compiling .pio\build\stm32test\FrameworkArduino\Stream.cpp.o
Compiling .pio\build\stm32test\FrameworkArduino\Tone.cpp.o
Compiling .pio\build\stm32test\FrameworkArduino\USBSerial.cpp.o
In file included from C:\Users\georg\.platformio\packages\framework-arduinoststm32\system\Drivers\STM32F4xx_HAL_Driver\Inc/stm32f4xx_hal.h:30:0,
                 from C:\Users\georg\.platformio\packages\framework-arduinoststm32\system\Drivers\CMSIS\Device\ST\STM32F4xx\Include/stm32f4xx.h:250,
                 from C:\Users\georg\.platformio\packages\framework-arduinoststm32\cores\arduino\stm32/stm32_def.h:34,        
                 from C:\Users\georg\.platformio\packages\framework-arduinoststm32\cores\arduino\stm32/clock.h:43,
                 from C:\Users\georg\.platformio\packages\framework-arduinoststm32\cores\arduino\wiring_time.h:23,
                 from C:\Users\georg\.platformio\packages\framework-arduinoststm32\cores\arduino\wiring.h:38,
                 from C:\Users\georg\.platformio\packages\framework-arduinoststm32\cores\arduino\Arduino.h:32,
                 from C:\Users\georg\.platformio\packages\framework-arduinoststm32\cores\arduino\HardwareSerial.cpp:26:       
C:\Users\georg\.platformio\packages\framework-arduinoststm32\system\STM32F4xx/stm32f4xx_hal_conf.h:4:10: fatal error: variant.h: No such file or directory

Which I notice this error:
Warning! Cannot find linker script for the current target!

I have exited VSCode and deleted both the .pio and .vscode directories as well as uninstalling PlatformIO and reinstalling it but I can’t seem to find how to solve this.

I can only guess, as I am very new to this. Sadly there seems not to be much people around here.

Did you import your project? I have some arduino and esp projects, and it is essential to choose the right board when importing my code. With the import, all necessary libraries and so on are copied to my project.

A thing I have mentioned is that I have also these red lines which tell me I have to change path bla. They occur at the strangest places, If there is a wrong include anywhere within my code, include after include and so on.

I´d definitely start checking the platformio.ini for right platform, board and framework.

I had moved my project from my desktop to my laptop. My code included a variant and that variant was not copied over to my laptop in the C:\Users\george\.platformio\packages\framework-arduinoststm32\variants directory

So the problem is solved but the error message was a bit misleading (at least to me).

2 Likes

Unfortunately, most compiler errors are, especially since they often fail on something, when the cuplrit is the line above… because it was on the next line it choked. It seems like it was trying to tell you that variants.h was missing…

i.e. At line 4, column 10 of stm32f4xx_hal_conf.h, after reading all of that line, the compiler was unable to find variant.h.