projectIO IDE very clunky

rayhall

Member
Hello ,
I hate to be critical as I did not pay much to use the projectIO IDE, but it sucks. It is very user unfriendly and basic tasks are difficult. I am constantly battling it not finding Include files. I have read about modifying the INI file so it knows where to find the header files. That sort of works, but as my project has a lot of cpp and H files I cannot get it to include them. If the project is in the raceboat folder what is so hard about make it look through all the sub folders. I have used quite a lot of embedded IDE software before and it never had a problem finding a include file.
If I am as silly old bastard, then tell me so but please find me a solution. I have the Teensy 4.1 board.
Ray.
 
Yes, PlatformIO has a learning curve. Somebody will be able to tell you how to add a folder to your search path. I have decided to stick with the Arduino IDE, which allows sub-folders in the sketch folder, but the IDE won't automatically search them for include files. For example, if you have sketch1.ino in the sketch1 folder, and a sub-folder named "sub" containing files utility.h and utility.cpp, you need this in your INO file:

#include "sub/utility.h"

If you just have #include "utility.h", the IDE won't find it. Yes, it kinda sucks, but you can work around it. I organize larger projects by creating and using my own libraries.
 
The compiler searches for headers in the current folder andf some system folders. If you want it to search in additional folders one needs to tell the compiler with additional -Ixxx parameters (https://gcc.gnu.org/onlinedocs/cpp/Search-Path.html). The Arduino ecosystem defines (and relies on) search path settings as defined here: https://arduino.github.io/arduino-cli/0.19/library-specification/

IMHO it would not be a good idea to extend the search path to say all subfolders of the sketch folder or even worse to all subfolders of the library folders. That has the potential to create a huge mess. E.g. if you have two folders, both containing a header with the same name, which one should be included? A larger project with a few libraries can consist of hundreds of folders with thousands of headers. Chances are that they don't all have distinctive names. How should the build system decide which one to include?

please find me a solution
As joepasquariello mentioned, the normal way is to specify the path to the header relative to the given search path. For libraries these are the folders specified in the link above. For own sketches the search path is just the current folder. I.e. if you want to include a header from your ino file it will find all headers in the sketch folder. If you have a header /myfolder/myheader.h and myheader.h contains #includes it will search for them in the current folder which now is /myfolder/. You can of course use relative paths. I.e. if you want to include /mysecondfolder/myheader.h from /myfolder/myheader.h you would write #include "../mysecondfolder/myheader.h". If you need to include a header from the sketch folder from myheader.h you would do #include "../someheader.h" and so on.

I generally try to setup my project folder structures to minimize header references to other folders. That allows for easy restructuring the project by moving folders around without having to adjust all paths.

Hope that helps
 
Last edited:
Taken from
https://stackoverflow.com/questions...en-include-filename-and-include-filename?rq=1

The <file> include tells the preprocessor to search in -I directories and in predefined directories first, then in the .c file's directory. The "file" include tells the preprocessor to search the source file's directory first, and then revert to -I and predefined. All destinations are searched anyway, only the order of search is different.

@joepasquariello
"I have decided to stick with the Arduino IDE, which allows sub-folders in the sketch folder"
All other development environments support that,
It was not until version 1.6.10 the Arduino team decided to add that feature.
Also you are actually restricted to the src subfolder, at least it you want the compiler to find any CPP files.
Also another problem is that the ide don't show those files, so you will need a external editor for them.

PlatformIO don't have such problems at all +the compilation is faster.
 
here is a example how a project structure could look like in platformIO
exampleFolderStructure.png

the contents of main.ino/main.cpp
Code:
#include <SomeImportedLib.h> // files and subfolders in .piolibdeps are automatically included
#include "inCurrentDir.h" // equals to "../src/inCurrentDir.h"
#include "../lib/projectlib/projectlib.h"
#include "../../commonLibs/someCommonLib/someCommonLib.h"
#include "../../project2/lib/projectLib/projectLib.h"

note. that I have put all libraries in separate folders
this is to separate them so that files with the same file names could be used in different libs
and also to clarify
 
PlatformIO don't have such problems at all +the compilation is faster.

@manicksan, thanks, I have no doubt that PlatformIO is superior to Arduino IDE. I use Notepad++ for all of my editing, and just use the Arduino IDE to build. The main reasons I stick with this method are (1) my projects are so far not too complex, (2) I understand how to use Arduino, (3) I have my files organized so I can update both Arduino and TeensyDuino without messing up my projects, and (4) I've tried a couple of times to use PlatformIO and just haven't had the time or patience to get up the learning curve. I'm hoping Teensy will eventually be supported in the new Arduino CLI and Pro IDE, and that will be my escape from the "classic" Arduino IDE.
 
I tried PlatformIO but, as you say the learning curve seems rather steep. I just want to do some programming which is where the learning should reside. In the end I plumped for VisualMicro with Visual Studio.
I am sure that I am not using all of it's features, but I am able to write code much easier and faster.
 
I would like to thank everyone. I have found exactly what I want and works for me. I installed Microsoft Visual Studio 2019 and added the Arduino IDE extension.
It is logical and easy to use and has no issues. Very happy.
Ray.
 
Back
Top