I’m a teacher in China. I teaching students C/C++ and MCU programming.
For many years, I have been looking for an integrated development software until I discovered PlatformIO.
It is so wonderful and powerful, and what’s more, easy to use and user-friendly. Now, instead of installing a bunch of development softwares/toolchains, I can teach my students with just only one development software. It’s great!
It seems that PlatformIO used for MCU programming. But sometimes the students want to use it for coding/learning C/C++, or test a piece of source code independent of MCUs. Just as the CodeBlocks(mingw version) can be used as an IDE to code C/C++. I know that the vscode can be configured as an IDE for C/C++ programming/learning, but it’s too complicated for students, and the configuration process make students bored.
MCU programming and C/C++ learning are inseparable, may the development team of PlatformIO add the tools/methods/tuitorials for the software (vscode+PlatformIO) as an IDE for C/C++ programming/learning?
Set the platform to native: Native — PlatformIO latest documentation
If you’re on Windows, you’ll have to install the compiler yourself however. You maybe could use the WSL but I’ve not gone down that road (yet).
Maybe this could enlighten you: https://code.visualstudio.com/remote-tutorials/wsl/getting-started
I’ve just tried it: it is easy. Just follow the steps to use VSCode remote in WSL and activate the Platformio extension in the remote window.
Only thing missing is the icons to build/upload… . But if you click the Pio icon you can open a Pio terminal and work via CLI.
P: I had platformio already installed in WSL, so I can just run the pio commands in WSL. Hence, I can run pio in the regular WSL too. Maybe that helped me using VSCode remote… Your mileage may vary.
Update: reopening the folder in VSCode remote adds the missing icon bar. I can now build by clicking (although prefer CLI as I need to run the program anyway).
Caveat: you C/C++ program will be built for Linux, not Win!
Thank you very much. I’m on windows, and I have installed codeblocks(mingw version), so the .exe toolchains, namely, gcc/g++/gdb exists in my folder.
I download the “platform-native-develop.zip” file, and unzip it. Then I opened the PlatformIO IDE, in the “PIO Home” page, there are some buttons in “Quick Access”, such as “New Project”, “Import Arduino Project”, “Open Project”, etc. I click the “Open Project” button, and locate the path to “\Downloads\platform-native-develop\examples\hello-world” which contains the “platformio.ini” file. After doing that, then the “HELLO-WORLD” project have been opened in the PlatformIO IDE. Then I clicked the “PlatformIO: Build” icon in the lower-left corner, but some errors appeared:
#include errors detected. Please update your includePath. Squiggles are disabled for this translation unit (C:\Users\wgt04\Downloads\platform-native-develop\examples\hello-world\src\main.c).
cannot open source file “stdio.h”
I think I’m lacking some configurations, can you give me some instructions?
P.S. The students will be confused with WSL, so I want to coding on windows, it’s easy to use.
- you just want to code in c/cpp in Windows
- you need 32 or 64 bit?
- output program executable in windows
- you talk about codeblocks, but that is something outside of VSCode or Platformio…
- you have a c/cpp toolchain installed but it is not available in VSCode (or only partially?)
Easiest is to install MingW and make sure you added the compiler to your PATH. (maybe follow this guide: MinGW C++ Download and Installation Instructions)
I installed MingW as per reference above et voilà:
Hi, bertmelis, sorry for my poor English. Thank you for your patience.
32 or 64 bit are available.
In my computer (windows, 64bit), I find that there are gcc.exe and g++.exe in the path:
and gdb32.exe in the path:
So I add the pathes above to the “environment variable” of “system properties”. Then I click the “PlatformIO: Build” icon in the lower-left corner, the “HELLO-WORLD” project compiled successfully.
I want to see the result, namely, the “Hello World from PlatformIO!”, just like the console application, but there is’n a button in the software to run the .exe file which generated by the gcc compiler.
Then I want to test the debug, when clicking “Debug/Starting Debuging” button, a dialog box and an error appeared:
Dialog box: The preLaunchTask ‘undefined’ terminated with exit code 1.
Error: Please setup environments in
So I can’t debug because of the error.
Is there someway to fix them?
Hi, following your picture, I get the result by typing “.pio/build/native/program”.
yes, the program doesn’t run automatically. You have to start it yourself.
Regarding your question: I’m not familiar with Pio debugging. If you want to do native programming, it may be easier to just follow Microsoft’s guide on VSCode: Get Started with C++ and Mingw-w64 in Visual Studio Code.
Thank you for giving me so many instructions, bertmelis.