I have just installed PlatformIO (under Windows 10), and am trying to compile a really simple test program (It consists of empty setup() and loop() function). However, I am not able to get it to build properly (neither via VSCode or from CLI). Here’s an example output from the CLI so I can see what’s happening (I included the -j 1 because otherwise I get several similar “not found” warnings):
c:\Users\xyz\src\testprog>pio run -v -j 1
Processing nanoatmega328 (platform: atmelavr; board: nanoatmega328; framework: arduino)
PLATFORM: Atmel AVR 2.2.0 > Arduino Nano ATmega328
HARDWARE: ATMEGA328P 16MHz, 2KB RAM, 30KB Flash
DEBUG: Current (simavr) On-board (simavr)
- framework-arduino-avr 5.0.0
- toolchain-atmelavr 1.50400.190710 (5.4.0)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 8 compatible libraries
Building in release mode
avr-g++ -o .pio\build\nanoatmega328\src\main.cpp.o -c -fno-exceptions -fno-threadsafe-statics -fpermissive -std=gnu++11 -Os -Wall -ffunction-sections -fdata-sections -flto -mmcu=atmega328p -DPLATFORMIO=40304 -DARDUINO_AVR_NANO -DF_CPU=16000000L -DARDUINO_ARCH_AVR -DARDUINO=10808 -Iinclude -Isrc -IC:\Users\xyz\.platformio\packages\framework-arduino-avr\cores\arduino -IC:\Users\xyz\.platformio\packages\framework-arduino-avr\variants\eightanaloginputs src\main.cpp
avr-g++: error: src\main.cpp: No such file or directory
avr-g++: fatal error: no input files
*** [.pio\build\nanoatmega328\src\main.cpp.o] Error 1
The avr-g++ command in the latter example is the correct one.
The pio.exe command seems to work for everything else. It can download libraries and frameworks, so I don’t think it is an issue of antivirus blocking process spawning. I am unable to test this anyway because this is on my work laptop, but I would expect some “access denied” error if that was the case, or at least that the AV wrote something in its logs.
Can you post your platformio.ini file from the project’s folder please? Thanks. There might be something there, maybe, perhaps!
In your command session, you are located in c:\Users\xyz\src\testprog – can you see the src/main.cpp file from there? Is there a platformio.ini file there too? If not, you need to be in the folder where the platformio.ini file is to be found, to run a compilation.
This line in your output:
is saying "find the file src/main.cpp, relative to where I am located, and compile it to an object file, then put it into .pio\build\nanoatmega328\src\main.cpp.o – also relative to where I am now.
Can you actually see the source file – src/main.cpp from within c:\Users\xyz\src\testprog?
Yes, the main.cpp file exists under c:\Users\xyz\src\testprog\src\. And the avr-g++ command does produce a main.cpp.o file under .pio\build\nanoatmega328\src as long as I run the command manually. It is only when pio.exe tries to run the excact same command that it fails. I run all commands from the project’s “root” directory (c:\Users\xyz\src\testprog).
This is my c:\Users\xyz\src\testprog\platformio.ini file:
; PlatformIO Project Configuration File
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
; Please visit documentation for the other options and examples
platform = atmelavr
board = nanoatmega328
framework = arduino
This is the only platformio.ini file I have. I tried to copy it together with the main.cpp file (just so I can say that I’ve tried it ), but that didn’t help.
No need to apologize I really appreciate the effort you’re putting into trying to help me.
And actually no, I didn’t follow all those instructions because I installed PIO from VSCode which I assume will perform all those steps for me. I only used the CLI to troubleshoot because it easier to find out what’s wrong when I can run the actual commands myself. However, the failed build result is the same both from VSCode and CLI.
But since you pointed them out, I tried to execute all the installation steps that seemed relevant, such as removing all Python installations (I had both 2.7 and 3.8) and reinstalling 3.8, installing virtualenv and enabling the development version of PIO. Nothing helped, though. I’m still stuck with that “src\main.cpp: No such file or directory” error, which I just don’t understand because I know that the file exists!
Yes, Python works just fine on it’s own. I am curios, though, about the python.exe (and associated files) located in the .platformio/penv/scripts directory. It seems like PIO insists on using those instead of the global Python installation, because if I temporary remove them PIO fails with the error “unable to create process”.
Not that it think it really matters, because they seem to work just as well as the global installation when I try to run Python scripts with them.
I had a look on my Linux system, In .platformio/penv/bin I have python, python3.6 and python3.
Python3 is the actual python 3.6.9 interpreter, the other two are symbolic links to this file. If I execute python3 I get the usual output:
Python 3.6.9 (default, Jul 17 2020, 12:50:27)
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
However, if I rename any of those files (or move them elsewhere) I can still compile PlatformIO code. Interesting that Windows 10 doesn’t allow that, but Linux does. I’m not convinced that, on Linux at least, PlatformIO is using those installed files.
I’m sorry to say that I’m at a bit of a loss as to why your systems isn’t working. Sorry.