I try to use VSCode+PIO in order to develop Windows console programs. Therefore, I installed the x86 Windows Desktop platform, from PIO. The hello-world program compiles, links etc. sucessfully, and I can execute the program.exe from the console. However, executing from VS Code fails with a message box:
The preLaunchTask 'undefined' terminated with exit code 1
In the VS code console the following message appears:
> Executing task: C:\Users\eble\.platformio\penv\Scripts\platformio.exe debug <
Error: Please setup environments in `platformio.ini` file
The terminal process terminated with exit code: 1
Terminal will be reused by tasks, press any key to close it.
This is my platformio.ini (2 lines), I didn’t modify it:
The .pioenvs directory doesn’t exist. Instead, the path to the executable should be: .pio/build/windows_x86/program.exe as is written correctly in my launch.json. I am not sure if this is related to my error.
In VSCode I hit the Run Button from the lefthand Activity Bar, then then RUN Symbol under the Edit menu. I can also choose Run->Start Debugging or Run->Run without Debugging. It doesn’t matter, I always get this error.
I suspect the Error: Please setup environments in platformio.ini file is a product of no debug related entries in the platformio.ini. I don’t think PlatformIO supports running a compiled executable locally, and it seems when you choose either Run -> Start Debugging or Run -> Start without Debugging that platformio debug is called in either case, hence the error.
AFAIK, the recommended way to run a compiled program is basically run it from the terminal, but hopefully someone will point out an easier way!
thanks for your reply. Sorry, it’s a little bit off-topic, but this is my background:
We are giving an embedded programming course at university for EE students. We will use a Pololu robot board, therefore we use VSCode/PIO. In the beginning, I would like to repeat C/C++ (without the embedded headachs). They are used (if they remember) to code in C/C++ with Qt Creator, so I thought it would be best to repeat C/C++ with VSCode so they (and I for that, I know VS Code for jscript and PHP only) can learn VSCode while refreshing C/C++ (native, on Windows) with at least hassle as possible (the C++ beast alone is hard enough IMHO). That means for me: The students don’t have to fiddle with VS Code json files, and they don’t have to launch the console manually, just like they are used with QT Creator. But using Qt Creator only for the repetition and than switching to VSCode is not the best option for me. I also have tried the VSCode “Easy C++ Projects” and “C/C++ Project Generator” extensions without much success in this respect, either.