I’m not sure if this is a CLion issue or PIO.
After starting a new project in CLion I’m trying to add source files. First I copied files from another project but got the message that they don’t belong in any project. I thought maybe they needed to be created by CLion to be added to the project but deleting a file and creating a new one doesn’t help.
I’m realizing now that I can build the file just fine so the PIO project is most likely fine but not parsed correctly by CLion.
Mostly it works great actually, I can still go to declarations and stuff. What doesn’t work is formatting the code, auto-complete and other nice features.
I’d appreciate any tips. If there’s no PIO issue I’ll post this as a CLion bug.
1 Like
Hi, I was in a very similar situation as well and just found a workaround today.
Here is my setup: CLion, PlatformIO-Core, and PlatformIO project are all under normal Windows directory, however the default toolchain of CLion was under WSL. If you have the same setup, try the following:
(1) Temporarily set a Windows toolchain (e.g., Visual Studio, MinGW) as CLion default
(2) platformio.ini
→ PlatformIO Project
→ Reload PlatformIO Project
. Everything should work by now
(3) Optionally, revert your default CLion toolchain setting. Your IDE should keep working as long you don’t reload the project
I hope this helps
I’m experiencing an issue where the main.c
file shows “File does not belong to any project target,” but this only happens with 8051 projects (Arduino-ESP32 projects are unaffected). Compilation and uploading work fine, but there’s no code completion.
My toolchain is configured with MinGW, and I haven’t changed it. The issue started after updating CLion and PlatformIO; previous versions worked without any problems. I attempted to revert to the older versions but didn’t succeed. I’ve also tried various solutions, such as switching the toolchain to “System Default” and clearing caches, but nothing worked.
Could someone please help? Thanks!
My versions:
- CLion: 2024.2.3
- PlatformIO Core: 6.1.16
- PlatformIO Home: 3.4.4
I’m using the same versions of CLion, PlatformIO Core and Home as you, and use MinGW (installed under Windows) as the default toolchain, same as you. And the only way I’ve found to reproduce your issue, i.e., CLion works fine with ESP32 but not with 8051 projects, is to uninstall MinGW or remove it from PATH.
Please check if you have MinGW installed on your system and can be found. Execute the following line in PowerShell or cmd:
gcc -v
You should have something similar to the following printed on the terminal if you do.
Using built-in specs.
COLLECT_GCC=C:\ProgramData\mingw64\mingw64\bin\gcc.exe
COLLECT_LTO_WRAPPER=C:/ProgramData/mingw64/mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/13.2.0/lto-wrapper.exe
Target: x86_64-w64-mingw32
...
If not, please install MinGW and make sure it was in PATH, and then, reload your PlatformIO project (you may need to restart Windows.)
If you do have MinGW installed and it can be found, my suggestion would be to reload the PlatformIO project and check the error message which should popout from the bottom-right corner. Click Display
and start the investigation from there.
Best wises